Commit 5e595241 authored by liujiangnan's avatar liujiangnan

feat: 拍照模板

parent 9f5f5457
import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
this._imageResList.push({ url: this.data.pic_url });
this._imageResList.push({ url: this.data.pic_url_2 });
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.audio_url });
}
addPreloadAnima() {
}
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
this.initPic();
this.initBtn();
this.initIcon();
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
pic1 = null;
pic2 = null;
initPic() {
const canvas = cc.find('Canvas');
const maxW = canvas.width * 0.7;
this.getSprNodeByUrl(this.data.pic_url, (sprNode) => {
const picNode1 = sprNode;
picNode1.scale = maxW / picNode1.width;
picNode1.baseX = picNode1.x;
canvas.addChild(picNode1);
this.pic1 = picNode1;
const labelNode = new cc.Node();
labelNode.color = cc.Color.YELLOW;
const label = labelNode.addComponent(cc.Label);
label.string = this.data.text;
label.fontSize = 60;
label.lineHeight = 60;
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent('cc.Label').font;
picNode1.addChild(labelNode);
});
this.getSprNodeByUrl(this.data.pic_url_2, (sprNode) => {
const picNode2 = sprNode;
picNode2.scale = maxW / picNode2.width;
canvas.addChild(picNode2);
picNode2.x = canvas.width;
picNode2.baseX = picNode2.x;
this.pic2 = picNode2;
const labelNode = new cc.Node();
const label = labelNode.addComponent(cc.RichText);
const size = 60
label.font = cc.find('Canvas/res/font/BRLNSDB').getComponent(cc.Label).font;
label.string = `<outline color=#751e00 width=4><size=${size}><color=#ffffff>${this.data.text}</color></size></outline>`
label.lineHeight = size;
picNode2.addChild(labelNode);
});
}
initIcon() {
const iconNode = this.getSprNode('icon');
iconNode.zIndex = 5;
iconNode.anchorX = 1;
iconNode.anchorY = 1;
iconNode.parent = cc.find('Canvas');
iconNode.x = iconNode.parent.width / 2 - 10;
iconNode.y = iconNode.parent.height / 2 - 10;
iconNode.on(cc.Node.EventType.TOUCH_START, () => {
this.playAudioByUrl(this.data.audio_url);
})
}
curPage = null;
initBtn() {
this.curPage = 0;
const bottomPart = cc.find('Canvas/bottomPart');
bottomPart.zIndex = 5; // 提高层级
bottomPart.x = bottomPart.parent.width / 2;
bottomPart.y = -bottomPart.parent.height / 2;
const leftBtnNode = bottomPart.getChildByName('btn_left');
//节点中添加了button组件 则可以添加click事件监听
leftBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 0) {
return;
}
this.curPage = 0
this.leftMove();
this.playLocalAudio('btn');
})
const rightBtnNode = bottomPart.getChildByName('btn_right');
//节点中添加了button组件 则可以添加click事件监听
rightBtnNode.on('click', () => {
if (!this._cantouch) {
return;
}
if (this.curPage == 1) {
return;
}
this.curPage = 1
this.rightMove();
// 游戏结束时需要调用这个方法通知系统作业完成
onHomeworkFinish();
this.playLocalAudio('btn');
})
}
leftMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
rightMove() {
this._cantouch = false;
const len = this.pic1.parent.width;
cc.tween(this.pic1)
.to(1, { x: this.pic1.baseX - len }, { easing: 'cubicInOut' })
.start();
cc.tween(this.pic2)
.to(1, { x: this.pic2.baseX - len }, { easing: 'cubicInOut' })
.call(() => {
this._cantouch = true;
})
.start();
}
// update (dt) {},
initListener() {
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b", "uuid": "4becf611-d0bc-4bd8-9bc9-b4d66646ada9",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.130612, "duration": 0.301724,
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "4641cae0-0d7a-4008-bc0e-ddf209310d28",
"downloadMode": 0,
"duration": 5.172245,
"subMetas": {}
}
\ No newline at end of file
...@@ -76,21 +76,18 @@ ...@@ -76,21 +76,18 @@
}, },
{ {
"__id__": 7 "__id__": 7
},
{
"__id__": 14
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 24 "__id__": 21
}, },
{ {
"__id__": 25 "__id__": 22
}, },
{ {
"__id__": 26 "__id__": 23
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -317,10 +314,10 @@ ...@@ -317,10 +314,10 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "8288e3d4-4c75-4b27-8f01-f7014417f4dd" "__uuid__": "124c4033-b4af-4f46-aad7-cfad80e198b2"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -335,7 +332,7 @@ ...@@ -335,7 +332,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bottomPart", "_name": "border",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 2
...@@ -345,11 +342,18 @@ ...@@ -345,11 +342,18 @@
"__id__": 8 "__id__": 8
}, },
{ {
"__id__": 11 "__id__": 15
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [
{
"__id__": 19
},
{
"__id__": 20
}
],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -361,8 +365,8 @@ ...@@ -361,8 +365,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 0, "width": 1200,
"height": 0 "height": 650
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -373,8 +377,8 @@ ...@@ -373,8 +377,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
635.132, 0,
-356.326, -11.937999999999988,
0, 0,
0, 0,
0, 0,
...@@ -396,23 +400,30 @@ ...@@ -396,23 +400,30 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "8c7k8ep/ZFNpO263+1QHz9" "_id": "4cUD/Pu2lDHrOxQ2myUhAG"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "btn_left", "_name": "pic_bg",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 7 "__id__": 7
}, },
"_children": [], "_children": [
{
"__id__": 9
},
{
"__id__": 11
}
],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 9 "__id__": 13
}, },
{ {
"__id__": 10 "__id__": 14
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -426,8 +437,8 @@ ...@@ -426,8 +437,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 61, "width": 630,
"height": 67 "height": 450
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -438,8 +449,8 @@ ...@@ -438,8 +449,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-148.464, -193.36599999999999,
34, 2.6189999999999998,
0, 0,
0, 0,
0, 0,
...@@ -461,123 +472,20 @@ ...@@ -461,123 +472,20 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "5ad2wLQLxIN5Eg7OHecSH6" "_id": "87udeot8pE05gj3zKcLfU0"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "84mqOgJ3JNqZrYVTEU8CjE"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "bcYN/4EKBJhbIAfovo9Ah1"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "btn_right", "_name": "camera_icon",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 7 "__id__": 8
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 12 "__id__": 10
},
{
"__id__": 13
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -591,8 +499,8 @@ ...@@ -591,8 +499,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 60, "width": 200,
"height": 66 "height": 200
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -603,8 +511,8 @@ ...@@ -603,8 +511,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
-47.164, 0,
34, 2.3299999999999983,
0, 0,
0, 0,
0, 0,
...@@ -626,14 +534,14 @@ ...@@ -626,14 +534,14 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "46i3stdzpHX6zQHTGnRsNE" "_id": "2bRO/FqQFE67tsjTzKpZf/"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 11 "__id__": 9
}, },
"_enabled": true, "_enabled": true,
"_materials": [ "_materials": [
...@@ -644,10 +552,10 @@ ...@@ -644,10 +552,10 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59" "__uuid__": "c3df061b-ee78-4bfd-ae31-2c477601a561"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -658,96 +566,22 @@ ...@@ -658,96 +566,22 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "42Sh8QS/BHn4WiGyPQPKPt" "_id": "584cPMy7JA371EskYgLDp4"
},
{
"__type__": "cc.Button",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"pressedColor": {
"__type__": "cc.Color",
"r": 211,
"g": 211,
"b": 211,
"a": 255
},
"_N$hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"hoverColor": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_N$disabledColor": {
"__type__": "cc.Color",
"r": 124,
"g": 124,
"b": 124,
"a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "1aj32fYY1IxLesa77E70Qu"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "res", "_name": "picture",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 2 "__id__": 8
},
"_children": [
{
"__id__": 15
},
{
"__id__": 18
}, },
"_children": [],
"_active": false,
"_components": [
{ {
"__id__": 21 "__id__": 12
} }
], ],
"_active": false,
"_components": [],
"_prefab": null, "_prefab": null,
"_opacity": 255, "_opacity": 255,
"_color": { "_color": {
...@@ -759,8 +593,8 @@ ...@@ -759,8 +593,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 0, "width": 590,
"height": 0 "height": 420
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -772,7 +606,7 @@ ...@@ -772,7 +606,7 @@
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 0,
0, 2.723,
0, 0,
0, 0,
0, 0,
...@@ -794,237 +628,117 @@ ...@@ -794,237 +628,117 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "0aAzbH6R1E+6AmGRrkKa5O" "_id": "9fqeIYCpdCFL2rZNgtv/xi"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Sprite",
"_name": "font", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "node": {
"__id__": 14 "__id__": 11
}, },
"_children": [ "_enabled": true,
"_materials": [
{ {
"__id__": 16 "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
} }
], ],
"_active": true, "_srcBlendFactor": 770,
"_components": [], "_dstBlendFactor": 771,
"_prefab": null, "_spriteFrame": {
"_opacity": 255, "__uuid__": "8cdb44ac-a3f6-449f-b354-7cd48cf84061"
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
}, },
"_anchorPoint": { "_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0
"z": 0
}, },
"_skewX": 0, "_fillStart": 0,
"_skewY": 0, "_fillRange": 0,
"_is3DNode": false, "_isTrimmedMode": true,
"_groupIndex": 0, "_atlas": null,
"groupIndex": 0, "_id": "673kE8GVpGmJlAlK3oywRh"
"_id": "9bLfcYeeNKrr524vzWchiM"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Sprite",
"_name": "BRLNSDB", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "node": {
"__id__": 15 "__id__": 8
}, },
"_children": [], "_enabled": true,
"_active": true, "_materials": [
"_components": [
{ {
"__id__": 17 "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
} }
], ],
"_prefab": null, "_srcBlendFactor": 770,
"_opacity": 255, "_dstBlendFactor": 771,
"_color": { "_spriteFrame": {
"__type__": "cc.Color", "__uuid__": "f9007be3-6ca1-4303-9a19-241afb4c9bcd"
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
}, },
"_anchorPoint": { "_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0
"z": 0
}, },
"_skewX": 0, "_fillStart": 0,
"_skewY": 0, "_fillRange": 0,
"_is3DNode": false, "_isTrimmedMode": true,
"_groupIndex": 0, "_atlas": null,
"groupIndex": 0, "_id": "2bIzAMvrpDw6GQCWIMbKZl"
"_id": "cfMLGsq0BMhJARv+ySMAxS"
}, },
{ {
"__type__": "cc.Label", "__type__": "cc.Widget",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 16 "__id__": 8
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "alignMode": 1,
"_srcBlendFactor": 770, "_target": null,
"_dstBlendFactor": 771, "_alignFlags": 45,
"_string": "", "_left": 91.63400000000001,
"_N$string": "", "_right": 478.366,
"_fontSize": 40, "_top": 97.381,
"_lineHeight": 40, "_bottom": 102.619,
"_enableWrapText": true, "_verticalCenter": 0,
"_N$file": { "_horizontalCenter": 0,
"__uuid__": "c551970e-b095-45f3-9f1d-25cde8b8deb1" "_isAbsLeft": true,
}, "_isAbsRight": true,
"_isSystemFontUsed": false, "_isAbsTop": true,
"_spacingX": 0, "_isAbsBottom": true,
"_batchAsBitmap": false, "_isAbsHorizontalCenter": true,
"_styleFlags": 0, "_isAbsVerticalCenter": true,
"_underlineHeight": 0, "_originalWidth": 630,
"_N$horizontalAlign": 0, "_originalHeight": 450,
"_N$verticalAlign": 0, "_id": "6bSWpu27VHt4eL/jzETozd"
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "9bNHNPu5lC7rQYyr8ai/sY"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "img", "_name": "upload",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 14 "__id__": 7
}, },
"_children": [ "_children": [],
{
"__id__": 19
}
],
"_active": true, "_active": true,
"_components": [], "_components": [
"_prefab": null, {
"_opacity": 255, "__id__": 16
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "53LUHHG2pEr79fyrvazXJs"
}, },
{ {
"__type__": "cc.Node", "__id__": 17
"_name": "icon",
"_objFlags": 0,
"_parent": {
"__id__": 18
}, },
"_children": [],
"_active": true,
"_components": [
{ {
"__id__": 20 "__id__": 18
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -1038,8 +752,8 @@ ...@@ -1038,8 +752,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 138, "width": 200,
"height": 141 "height": 179
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1050,8 +764,8 @@ ...@@ -1050,8 +764,8 @@
"__type__": "TypedArray", "__type__": "TypedArray",
"ctor": "Float64Array", "ctor": "Float64Array",
"array": [ "array": [
0, 321.499,
0, 14.268,
0, 0,
0, 0,
0, 0,
...@@ -1073,24 +787,28 @@ ...@@ -1073,24 +787,28 @@
"_is3DNode": false, "_is3DNode": false,
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"_id": "1blU2OArJIfoC9XfupGxJG" "_id": "6dYJpZFq1H+KwLmQhhtzPx"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 19 "__id__": 15
}, },
"_enabled": true, "_enabled": true,
"_materials": [], "_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a" "__uuid__": "8647fd61-ce42-47a0-93ac-1e00c894b101"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 0,
"_fillType": 0, "_fillType": 0,
"_fillCenter": { "_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
...@@ -1101,150 +819,161 @@ ...@@ -1101,150 +819,161 @@
"_fillRange": 0, "_fillRange": 0,
"_isTrimmedMode": true, "_isTrimmedMode": true,
"_atlas": null, "_atlas": null,
"_id": "03GEWUEZJGyKormWgIWCtM" "_id": "e92907okJOnKsErHPd2Els"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Widget",
"_name": "audio", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "node": {
"__id__": 14 "__id__": 15
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 32,
"_left": 821.499,
"_right": 178.50099999999998,
"_top": 221.232,
"_bottom": 249.768,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 200,
"_originalHeight": 179,
"_id": "d83uTdSdJDXphCEYprL/3d"
}, },
"_children": [
{ {
"__id__": 22 "__type__": "cc.Button",
} "_name": "",
], "_objFlags": 0,
"_active": true, "node": {
"_components": [], "__id__": 15
"_prefab": null, },
"_opacity": 255, "_enabled": true,
"_color": { "_normalMaterial": null,
"_grayMaterial": null,
"duration": 0.1,
"zoomScale": 1.2,
"clickEvents": [],
"_N$interactable": true,
"_N$enableAutoGrayEffect": false,
"_N$transition": 0,
"transition": 0,
"_N$normalColor": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 255,
"g": 255, "g": 255,
"b": 255, "b": 255,
"a": 255 "a": 255
}, },
"_contentSize": { "_N$pressedColor": {
"__type__": "cc.Size", "__type__": "cc.Color",
"width": 0, "r": 211,
"height": 0 "g": 211,
"b": 211,
"a": 255
}, },
"_anchorPoint": { "pressedColor": {
"__type__": "cc.Vec2", "__type__": "cc.Color",
"x": 0.5, "r": 211,
"y": 0.5 "g": 211,
"b": 211,
"a": 255
}, },
"_trs": { "_N$hoverColor": {
"__type__": "TypedArray", "__type__": "cc.Color",
"ctor": "Float64Array", "r": 255,
"array": [ "g": 255,
0, "b": 255,
0, "a": 255
0,
0,
0,
0,
1,
1,
1,
1
]
}, },
"_eulerAngles": { "hoverColor": {
"__type__": "cc.Vec3", "__type__": "cc.Color",
"x": 0, "r": 255,
"y": 0, "g": 255,
"z": 0 "b": 255,
"a": 255
}, },
"_skewX": 0, "_N$disabledColor": {
"_skewY": 0, "__type__": "cc.Color",
"_is3DNode": false, "r": 124,
"_groupIndex": 0, "g": 124,
"groupIndex": 0, "b": 124,
"_id": "d9f+b0lmZGSJJae6zrADhp" "a": 255
},
"_N$normalSprite": null,
"_N$pressedSprite": null,
"pressedSprite": null,
"_N$hoverSprite": null,
"hoverSprite": null,
"_N$disabledSprite": null,
"_N$target": null,
"_id": "7bi70+P3lM04Z9sZsGAMfh"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Sprite",
"_name": "btn", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "node": {
"__id__": 21 "__id__": 7
}, },
"_children": [], "_enabled": true,
"_active": true, "_materials": [
"_components": [
{ {
"__id__": 23 "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
} }
], ],
"_prefab": null, "_srcBlendFactor": 770,
"_opacity": 255, "_dstBlendFactor": 771,
"_color": { "_spriteFrame": {
"__type__": "cc.Color", "__uuid__": "1a85a24c-074c-4de0-9bdf-49088fc69d30"
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
}, },
"_anchorPoint": { "_type": 0,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
0,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0
"z": 0
}, },
"_skewX": 0, "_fillStart": 0,
"_skewY": 0, "_fillRange": 0,
"_is3DNode": false, "_isTrimmedMode": true,
"_groupIndex": 0, "_atlas": null,
"groupIndex": 0, "_id": "abvMMDRodDtJL7eCOVR2Dm"
"_id": "e87DSaFCVJfb2PAUkf4/o7"
}, },
{ {
"__type__": "cc.AudioSource", "__type__": "cc.Widget",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 22 "__id__": 7
}, },
"_enabled": true, "_enabled": true,
"_clip": { "alignMode": 1,
"__uuid__": "f0680ae0-c079-45ef-abd7-9e63d90b982b" "_target": null,
}, "_alignFlags": 45,
"_volume": 1, "_left": 40,
"_mute": false, "_right": 40,
"_loop": false, "_top": 46.93799999999999,
"_firstlyEnabled": true, "_bottom": 23.062000000000012,
"playOnLoad": false, "_verticalCenter": 0,
"preload": false, "_horizontalCenter": 0,
"_id": "dey05oKrBIspvsDa6pOIQz" "_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1200,
"_originalHeight": 650,
"_id": "ecKoR+Gw1Js6+/4CNuGYL1"
}, },
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
......
import { buttonOnClick, onHomeworkFinish, getSpriteFrimeByUrl } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
const { ccclass, property } = cc._decorator;
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
addPreloadImage() {
// TODO 根据自己的配置预加载图片资源
}
addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源
}
addPreloadAnima() {
}
onLoadEnd() {
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this.initData();
this.initView();
this.initListener();
}
_cantouch = null;
initData() {
// 所有全局变量 默认都是null
this._cantouch = true;
}
initView() {
this.initBg();
window["cameraHandler"].takePictureCallback = (err, url) => {
if (err) {
console.log(err);
return;
}
const pic = cc.find(`Canvas/border/pic_bg/picture`);
getSpriteFrimeByUrl(url, (frame) => {
pic.getComponent(cc.Sprite).spriteFrame = frame;
pic.active = true;
});
}
}
initBg() {
const bgNode = cc.find('Canvas/bg');
bgNode.scale = this._mapScaleMax;
}
initListener() {
const btn = cc.find(`Canvas/border/upload`);
buttonOnClick(btn, () => {
window["cameraHandler"].openCamera();
});
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
return new Promise((resolve, reject) => {
const id = cc.audioEngine.playEffect(audio.clip, false);
cc.audioEngine.setFinishCallback(id, () => {
resolve(id);
});
})
}
}
...@@ -464,3 +464,20 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu ...@@ -464,3 +464,20 @@ export function callMiddleLayerFunction(apiName: string, data: any, callback: Fu
} }
} }
export function buttonOnClick(button, callback, scale = 1.0) {
button.on('click', () => {
if (button['cantClick']) {
return;
}
button['cantClick'] = true;
cc.tween(button)
.to(0.1, { scale: scale * 1.1 })
.to(0.1, { scale: scale })
.call(() => {
button['cantClick'] = false;
callback && callback();
})
.start();
});
}
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f", "uuid": "94d00aab-b23f-45ad-9ab2-57c92ef61efb",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 366, "width": 2436,
"height": 336, "height": 1125,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"1orange": { "bg": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa", "uuid": "124c4033-b4af-4f46-aad7-cfad80e198b2",
"rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f", "rawTextureUuid": "94d00aab-b23f-45ad-9ab2-57c92ef61efb",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
"offsetX": 0, "offsetX": 0,
"offsetY": -0.5, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 1, "trimY": 0,
"width": 366, "width": 2436,
"height": 335, "height": 1125,
"rawWidth": 366, "rawWidth": 2436,
"rawHeight": 336, "rawHeight": 1125,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "d582359e-924e-4ee9-9964-1fc4bb417e71", "uuid": "98259c2e-7104-4202-95be-084d18b974f7",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 61, "width": 2436,
"height": 67, "height": 1125,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"btn_right": { "border": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59", "uuid": "1a85a24c-074c-4de0-9bdf-49088fc69d30",
"rawTextureUuid": "d582359e-924e-4ee9-9964-1fc4bb417e71", "rawTextureUuid": "98259c2e-7104-4202-95be-084d18b974f7",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
"offsetX": -0.5, "offsetX": -10,
"offsetY": 0.5, "offsetY": -54.5,
"trimX": 0, "trimX": 44,
"trimY": 0, "trimY": 122,
"width": 60, "width": 2328,
"height": 66, "height": 990,
"rawWidth": 61, "rawWidth": 2436,
"rawHeight": 67, "rawHeight": 1125,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "9a79969a-0506-48d4-bc98-3c05d109b027", "uuid": "8f0c762f-e329-494c-a1f2-a47ae2223944",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 61, "width": 368,
"height": 67, "height": 368,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"btn_left": { "camera": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5", "uuid": "c3df061b-ee78-4bfd-ae31-2c477601a561",
"rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027", "rawTextureUuid": "8f0c762f-e329-494c-a1f2-a47ae2223944",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
...@@ -22,10 +22,10 @@ ...@@ -22,10 +22,10 @@
"offsetY": 0, "offsetY": 0,
"trimX": 0, "trimX": 0,
"trimY": 0, "trimY": 0,
"width": 61, "width": 368,
"height": 67, "height": 368,
"rawWidth": 61, "rawWidth": 368,
"rawHeight": 67, "rawHeight": 368,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
{
"ver": "2.3.5",
"uuid": "3117ad9b-9b1d-4c81-bd0f-859f96c669de",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 1400,
"height": 800,
"platformSettings": {},
"subMetas": {
"pic_bg": {
"ver": "1.0.4",
"uuid": "f9007be3-6ca1-4303-9a19-241afb4c9bcd",
"rawTextureUuid": "3117ad9b-9b1d-4c81-bd0f-859f96c669de",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -4.5,
"offsetY": 2,
"trimX": 15,
"trimY": 16,
"width": 1361,
"height": 764,
"rawWidth": 1400,
"rawHeight": 800,
"borderTop": 41,
"borderBottom": 51,
"borderLeft": 50.5,
"borderRight": 53.5,
"subMetas": {}
}
}
}
\ No newline at end of file
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "18d07592-51a9-421e-8972-0f67b68d29e1", "uuid": "393795ab-53db-470d-98f2-122346ae543c",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
"premultiplyAlpha": false, "premultiplyAlpha": false,
"genMipmaps": false, "genMipmaps": false,
"packable": true, "packable": true,
"width": 144, "width": 380,
"height": 144, "height": 340,
"platformSettings": {}, "platformSettings": {},
"subMetas": { "subMetas": {
"icon": { "upload": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a", "uuid": "8647fd61-ce42-47a0-93ac-1e00c894b101",
"rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1", "rawTextureUuid": "393795ab-53db-470d-98f2-122346ae543c",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
"offsetX": 0, "offsetX": 0.5,
"offsetY": -0.5, "offsetY": -0.5,
"trimX": 3, "trimX": 7,
"trimY": 2, "trimY": 10,
"width": 138, "width": 367,
"height": 141, "height": 321,
"rawWidth": 144, "rawWidth": 380,
"rawHeight": 144, "rawHeight": 340,
"borderTop": 0, "borderTop": 0,
"borderBottom": 0, "borderBottom": 0,
"borderLeft": 0, "borderLeft": 0,
......
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
</div> </div>
<!-- </div> --> <!-- </div> -->
<!-- camera -->
<div id="VideoContainer" style="position: absolute; top: 0px; left: 0px; bottom: 0px; right: 0px; display: none;">
<video id="video" autoplay style="width: 100%;height: 100%;"></video>
</div>
<!-- <p class="footer">Made with <a href="https://www.cocos.com/products#CocosCreator" title="cocos creator">Cocos Creator</a></p> --> <!-- <p class="footer">Made with <a href="https://www.cocos.com/products#CocosCreator" title="cocos creator">Cocos Creator</a></p> -->
<script src="src/settings.js" charset="utf-8"></script> <script src="src/settings.js" charset="utf-8"></script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment