Commit feb3aa3e authored by 李维's avatar 李维

完成拖拽功能

parent a9b979a8
{
"ver": "1.1.2",
"uuid": "1ec6f758-fc48-47d3-bad6-e26a6ebd77bf",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
[
{
"__type__": "cc.Prefab",
"_name": "",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"asyncLoadAssets": false,
"readonly": false
},
{
"__type__": "cc.Node",
"_name": "VideoControlBar",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 8
},
{
"__id__": 10
},
{
"__id__": 21
},
{
"__id__": 24
}
],
"_active": true,
"_components": [
{
"__id__": 27
},
{
"__id__": 28
}
],
"_prefab": {
"__id__": 29
},
"_opacity": 255,
"_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": [
640,
100,
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": ""
},
{
"__type__": "cc.Node",
"_name": "progress",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
}
],
"_active": true,
"_components": [
{
"__id__": 6
}
],
"_prefab": {
"__id__": 7
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1053,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
8,
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": ""
},
{
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
}
],
"_prefab": {
"__id__": 5
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 30,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-528,
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": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "91c20c73-41fc-4aaf-90f6-5f0e30fc0857"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "406wZYop9D2aRpagd7nuiR",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "b3de4dee-0204-4146-9ae3-fe5790515778"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "480B29nphJA6YED4DUIFgt",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "markNode",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 9
},
"_opacity": 255,
"_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": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "34twh3ifZIPaYKCWna57S6",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "controlButton",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 11
},
{
"__id__": 14
},
{
"__id__": 17
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 20
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 155
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-650,
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": ""
},
{
"__type__": "cc.Node",
"_name": "play",
"_objFlags": 0,
"_parent": {
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 12
}
],
"_prefab": {
"__id__": 13
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 154
},
"_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": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "45b208cd-8797-4452-b5bc-9c6a3a31fcea"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "c18o1hS1dJaIENF2MvURFk",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "pause",
"_objFlags": 0,
"_parent": {
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 15
}
],
"_prefab": {
"__id__": 16
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 154
},
"_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": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "dbd46980-78b5-4992-8c7d-038b0134885f"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "0doY5vk+RCELITL8R3G2gk",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "replay",
"_objFlags": 0,
"_parent": {
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 18
}
],
"_prefab": {
"__id__": 19
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 155
},
"_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": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 17
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "ba88dfb3-89c5-4e4c-9fe6-7c6f6f28a36c"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "caR3d+1m9HkaQbf5Mix4vV",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "e6EaEyxpVO14/aMaOTGN39",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "dragButton",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 22
}
],
"_prefab": {
"__id__": 23
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 52,
"height": 57
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-520,
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": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 21
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "7ac0160b-8705-4710-b65d-3bab72310bbc"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "305Bnt78BML5iK0PU65G5T",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "markPoint",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 25
}
],
"_prefab": {
"__id__": 26
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 15,
"height": 15
},
"_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": ""
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "3fc25a16-8cbc-4cdd-99a2-5251bb1dcf5d"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "359axb3wRFnpR16d4pl6Xc",
"sync": false
},
{
"__type__": "28e11HTXPtGa7wWg93PflND",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"_id": ""
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 20,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 100,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": ""
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "",
"sync": false
}
]
\ No newline at end of file
{
"ver": "1.2.9",
"uuid": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9",
"optimizationPolicy": "AUTO",
"asyncLoadAssets": false,
"readonly": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "ebd1c92e-da1e-4a16-b61b-54a09be17ce4",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
start () {
this.init();
this.initVideoBtn();
this.addListener();
this.initdDrag();
},
barBaseW: 0, // 进度条宽度
bgProgress: null, // 进度条背景
bar: null, // 进度条填充
dragBtn: null, // 进度条拖拽按钮
controlBtn: null, // 按钮点击事件挂在这个上面
playBtn: null, // 播放按钮
pauseBtn: null, // 暂停按钮
replayBtn: null, // 重播按钮
init() {
console.log("Init video control component.")
this.bgProgress = cc.find('progress', this.node);
this.bar = cc.find('progress/bar', this.node);
this.dragBtn = cc.find('dragButton', this.node);
this.controlBtn = cc.find('controlButton', this.node);
this.playBtn = cc.find('controlButton/play', this.node);
this.pauseBtn = cc.find('controlButton/pause', this.node);
this.replayBtn = cc.find('controlButton/replay', this.node);
this.playBtn.active = true;
this.pauseBtn.active = false;
this.replayBtn.active = false;
this.videoStatus = 0; // 0:暂停 1:播放中 2:重播
this.barBaseW = this.bgProgress.width;;
this.setProgress(0);
},
initVideoBtn() {
this.controlBtn.addComponent(cc.Button);
this.controlBtn.on('click', () => {
if (this.videoStatus==null || this.videoStatus ==0) {
this.refreshVideoBtnState(1);
this.node.emit('video_btn_click', true)
} else if (this.videoStatus ==1) {
this.refreshVideoBtnState(0);
this.node.emit('video_btn_click', false)
}
});
},
userDragStart: null,
initdDrag() {
const dragStartX = -520;
const maxX = this.bgProgress.width + dragStartX ;
const minX = dragStartX;
this.dragBtn.off(cc.Node.EventType.TOUCH_START);
this.dragBtn.on(cc.Node.EventType.TOUCH_START, (e) => {
this.userDragStart = true;
this.node.emit('on_drag_button', true);
});
this.dragBtn.off(cc.Node.EventType.TOUCH_MOVE);
this.dragBtn.on(cc.Node.EventType.TOUCH_MOVE, (e) => {
const worldPos = e.getLocation();
const localPos = this.dragBtn.parent.convertToNodeSpaceAR(worldPos);
let newX = localPos.x;
newX = Math.min(maxX, Math.max(newX, minX));
this.dragBtn.x = newX;
const percent = Math.abs(newX-dragStartX) / Math.abs(this.bgProgress.width);
this.setProgress(percent);
this.node.emit('on_drag_percent', percent)
});
this.dragBtn.off(cc.Node.EventType.TOUCH_ENDED);
this.dragBtn.on(cc.Node.EventType.TOUCH_ENDED, (e) => {
if(this.userDragStart) {
this.userDragStart = false;
this.node.emit('on_drag_button', false);
}
});
this.dragBtn.on(cc.Node.EventType.MOUSE_UP, (e) => {
if(this.userDragStart) {
this.userDragStart = false;
this.node.emit('on_drag_button', false);
}
});
cc.find('Canvas').on(cc.Node.EventType.TOUCH_ENDED, (e) => {
if(this.userDragStart) {
this.userDragStart = false;
this.node.emit('on_drag_button', false);
}
});
cc.find('Canvas').on(cc.Node.EventType.MOUSE_UP, (e) => {
if(this.userDragStart) {
this.userDragStart = false;
this.node.emit('on_drag_button', false);
}
});
},
// 0:暂停 1:播放中 2:重播
videoStatus: null,
refreshVideoBtnState(status) {
this.videoStatus = status;
switch(status) {
case 0:
this.playBtn.active = true;
this.pauseBtn.active = false;
this.replayBtn.active = false;
break;
case 1:
this.playBtn.active = false;
this.pauseBtn.active = true;
this.replayBtn.active = false;
break;
case 2:
this.playBtn.active = false;
this.pauseBtn.active = false;
this.replayBtn.active = true;
break;
default:
this.playBtn.active = true;
this.pauseBtn.active = false;
this.replayBtn.active = false;
break;
};
},
addListener() {
this.node.on('video_play_end', () => {
this.refreshVideoBtnState();
})
this.node.on('update_video_progress', (value)=>{
if(!this.userDragStart) {
this.setProgress(value);
}
})
this.node.on('update_video_status', (status)=>{
this.refreshVideoBtnState(status);
})
this.node.on("set_mark_points", (data)=>{
const markPoint = cc.find("markPoint", this.node);
const markPointsContainer = cc.find("markNode", this.node);
for(let i=0; i<data.length; i++) {
const newPoint = cc.instantiate(markPoint);
newPoint.x = -520 + this.bgProgress.width * data[i];
newPoint.active = true;
markPointsContainer.addChild(newPoint);
}
})
},
setProgress(progress) {
const dragStartX = -520;
setTimeout(() => {
const w = this.barBaseW * progress;
this.bar.width = w;
if(!this.userDragStart) {
this.dragBtn.x = dragStartX + w;
}
}, 1);
},
});
{
"ver": "1.0.8",
"uuid": "28e111d3-5cfb-466b-bc16-83ddcf7e5343",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "5c56fef8-fa7a-48c9-a282-d5c355deee22",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2c82c218-fb9f-4368-9761-2ba189614e5c",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 157,
"height": 157,
"platformSettings": {},
"subMetas": {
" 重播按钮": {
"ver": "1.0.4",
"uuid": "ba88dfb3-89c5-4e4c-9fe6-7c6f6f28a36c",
"rawTextureUuid": "2c82c218-fb9f-4368-9761-2ba189614e5c",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -1,
"trimX": 1,
"trimY": 2,
"width": 155,
"height": 155,
"rawWidth": 157,
"rawHeight": 157,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "986b65e8-dc02-48df-a92a-0743e5e1c828",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 52,
"height": 57,
"platformSettings": {},
"subMetas": {
"可拖动按钮": {
"ver": "1.0.4",
"uuid": "7ac0160b-8705-4710-b65d-3bab72310bbc",
"rawTextureUuid": "986b65e8-dc02-48df-a92a-0743e5e1c828",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 52,
"height": 57,
"rawWidth": 52,
"rawHeight": 57,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "252835f3-3f05-40e2-8b64-6eb98fa01ec6",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 157,
"height": 157,
"platformSettings": {},
"subMetas": {
"播放按钮": {
"ver": "1.0.4",
"uuid": "dbd46980-78b5-4992-8c7d-038b0134885f",
"rawTextureUuid": "252835f3-3f05-40e2-8b64-6eb98fa01ec6",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 1,
"trimY": 2,
"width": 155,
"height": 154,
"rawWidth": 157,
"rawHeight": 157,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "dee7ff5a-af4c-4ee3-998f-bb4659a98a69",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 157,
"height": 157,
"platformSettings": {},
"subMetas": {
"暂停按钮": {
"ver": "1.0.4",
"uuid": "45b208cd-8797-4452-b5bc-9c6a3a31fcea",
"rawTextureUuid": "dee7ff5a-af4c-4ee3-998f-bb4659a98a69",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": -0.5,
"trimX": 1,
"trimY": 2,
"width": 155,
"height": 154,
"rawWidth": 157,
"rawHeight": 157,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "860e9678-48af-4e4b-83d2-9e5a5dbc147e",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 1069,
"height": 28,
"platformSettings": {},
"subMetas": {
"灰色进度条": {
"ver": "1.0.4",
"uuid": "b3de4dee-0204-4146-9ae3-fe5790515778",
"rawTextureUuid": "860e9678-48af-4e4b-83d2-9e5a5dbc147e",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 6,
"offsetY": 0,
"trimX": 14,
"trimY": 0,
"width": 1053,
"height": 28,
"rawWidth": 1069,
"rawHeight": 28,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "253c929f-8f96-46ed-9bde-7b0bf213e793",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 15,
"height": 15,
"platformSettings": {},
"subMetas": {
"跳题标记点": {
"ver": "1.0.4",
"uuid": "3fc25a16-8cbc-4cdd-99a2-5251bb1dcf5d",
"rawTextureUuid": "253c929f-8f96-46ed-9bde-7b0bf213e793",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 15,
"height": 15,
"rawWidth": 15,
"rawHeight": 15,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "733f270e-d4a3-4c16-a4a7-e2cdf0e579f0",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 628,
"height": 25,
"platformSettings": {},
"subMetas": {
"黄色的进度条-中间": {
"ver": "1.0.4",
"uuid": "91c20c73-41fc-4aaf-90f6-5f0e30fc0857",
"rawTextureUuid": "733f270e-d4a3-4c16-a4a7-e2cdf0e579f0",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": -1,
"offsetY": 0,
"trimX": 1,
"trimY": 0,
"width": 624,
"height": 25,
"rawWidth": 628,
"rawHeight": 25,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 19,
"borderRight": 19,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "c52631a0-a14e-4fdb-af58-3df90427f4ac",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": true,
"genMipmaps": false,
"packable": true,
"width": 1069,
"height": 28,
"platformSettings": {},
"subMetas": {
"黄色的进度条-满的": {
"ver": "1.0.4",
"uuid": "69891fc9-0258-4a67-ac2c-9d26cae3cffa",
"rawTextureUuid": "c52631a0-a14e-4fdb-af58-3df90427f4ac",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 6,
"offsetY": 0,
"trimX": 14,
"trimY": 0,
"width": 1053,
"height": 28,
"rawWidth": 1069,
"rawHeight": 28,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 16,
"borderRight": 6,
"subMetas": {}
}
}
}
\ No newline at end of file
......@@ -79,18 +79,21 @@
},
{
"__id__": 10
},
{
"__id__": 39
}
],
"_active": true,
"_components": [
{
"__id__": 36
"__id__": 65
},
{
"__id__": 37
"__id__": 66
},
{
"__id__": 38
"__id__": 67
}
],
"_prefab": null,
......@@ -247,43 +250,1023 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
"__id__": 3
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 640,
"_right": 640,
"_top": 470,
"_bottom": 470,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": "a3W+F+0tFAFJzUnY+BaTiV"
},
{
"__type__": "cc.Node",
"_name": "hand",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 7
}
],
"_prefab": null,
"_opacity": 255,
"_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": "a9n85YLmlImaErX3F/ubGc"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "Armature",
"_animationName": "normal",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "ac9a69d6-8ef7-4ae8-b84a-73f1ffbfeb1c#3592528d-2b01-442c-ad9e-c701ab6dd067",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "ac9a69d6-8ef7-4ae8-b84a-73f1ffbfeb1c"
},
"_N$dragonAtlasAsset": {
"__uuid__": "3592528d-2b01-442c-ad9e-c701ab6dd067"
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 1,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "b5ZWY5+bFE3YNqJ+CrU6nq"
},
{
"__type__": "cc.Node",
"_name": "goodjob",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 9
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 700,
"height": 700
},
"_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": "f23hV9mnBBYZ1OXVQg3VZs"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "armatureName",
"_animationName": "newAnimation",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "9d28773b-d69f-4fc8-b675-16fde99a4712#f615b7c8-a715-4f8d-88f6-c6b0765ede74",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "9d28773b-d69f-4fc8-b675-16fde99a4712"
},
"_N$dragonAtlasAsset": {
"__uuid__": "f615b7c8-a715-4f8d-88f6-c6b0765ede74"
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 1,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "66t644bDFDb73XispqPIHj"
},
{
"__type__": "cc.Node",
"_name": "VideoControlBar",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [
{
"__id__": 11
},
{
"__id__": 17
},
{
"__id__": 19
},
{
"__id__": 30
},
{
"__id__": 33
}
],
"_active": true,
"_components": [
{
"__id__": 36
},
{
"__id__": 37
}
],
"_prefab": {
"__id__": 38
},
"_opacity": 255,
"_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,
370,
0,
0,
0,
0,
1,
0.7,
0.7,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "e5bF4KDU1F0ZXH6XOAcyPh"
},
{
"__type__": "cc.Node",
"_name": "progress",
"_objFlags": 0,
"_parent": {
"__id__": 10
},
"_children": [
{
"__id__": 12
}
],
"_active": true,
"_components": [
{
"__id__": 15
}
],
"_prefab": {
"__id__": 16
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 1053,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
8,
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": "b8DFmtrzpILI8tvxl45iMF"
},
{
"__type__": "cc.Node",
"_name": "bar",
"_objFlags": 0,
"_parent": {
"__id__": 11
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
}
],
"_prefab": {
"__id__": 14
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 30,
"height": 28
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-528,
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": "2foXUCKE5BS7DPMKtOI8r9"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "91c20c73-41fc-4aaf-90f6-5f0e30fc0857"
},
"_type": 1,
"_sizeMode": 0,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "7evFazcUNOu6fHqFYdjyDH"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "406wZYop9D2aRpagd7nuiR",
"sync": false
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 11
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "b3de4dee-0204-4146-9ae3-fe5790515778"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "17JjUkgOVEOqt4lOqtnX86"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "480B29nphJA6YED4DUIFgt",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "markNode",
"_objFlags": 0,
"_parent": {
"__id__": 10
},
"_children": [],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 18
},
"_opacity": 255,
"_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": "81KVs/SbZPcKwSKLz/nndo"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "34twh3ifZIPaYKCWna57S6",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "controlButton",
"_objFlags": 0,
"_parent": {
"__id__": 10
},
"_children": [
{
"__id__": 20
},
{
"__id__": 23
},
{
"__id__": 26
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 29
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 155
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
-650,
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": "6dmH2RBYdBjZPm1Nd+E4A+"
},
{
"__type__": "cc.Node",
"_name": "play",
"_objFlags": 0,
"_parent": {
"__id__": 19
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 21
}
],
"_prefab": {
"__id__": 22
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 154
},
"_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": "4dXD7kKj1CkY4MaCJg8cOw"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "45b208cd-8797-4452-b5bc-9c6a3a31fcea"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "d0IayV8PRKzp8LiwXDVIrH"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "c18o1hS1dJaIENF2MvURFk",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "pause",
"_objFlags": 0,
"_parent": {
"__id__": 19
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 24
}
],
"_prefab": {
"__id__": 25
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 154
},
"_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": "95bI4531NJyrJSZV0fayex"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 23
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "dbd46980-78b5-4992-8c7d-038b0134885f"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "adhS8IX3pBgrN8J1hWpNOl"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "0doY5vk+RCELITL8R3G2gk",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "replay",
"_objFlags": 0,
"_parent": {
"__id__": 19
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 27
}
],
"_prefab": {
"__id__": 28
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 155,
"height": 155
},
"_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": "eftZh/6TZMKrRBgJqHsEpf"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 26
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 45,
"_left": 640,
"_right": 640,
"_top": 470,
"_bottom": 470,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 1280,
"_originalHeight": 720,
"_id": "a3W+F+0tFAFJzUnY+BaTiV"
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "ba88dfb3-89c5-4e4c-9fe6-7c6f6f28a36c"
},
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "52Std+h5BI96wIxGPGfVE9"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "caR3d+1m9HkaQbf5Mix4vV",
"sync": false
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "e6EaEyxpVO14/aMaOTGN39",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "hand",
"_name": "dragButton",
"_objFlags": 0,
"_parent": {
"__id__": 2
"__id__": 10
},
"_children": [],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 7
"__id__": 31
}
],
"_prefab": null,
"_prefab": {
"__id__": 32
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
......@@ -294,8 +1277,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
"width": 52,
"height": 57
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -306,7 +1289,7 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
-520,
0,
0,
0,
......@@ -329,14 +1312,14 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "a9n85YLmlImaErX3F/ubGc"
"_id": "c2KHpc9t9NjLjaBpsfqpPy"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 6
"__id__": 30
},
"_enabled": true,
"_materials": [
......@@ -344,48 +1327,53 @@
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "Armature",
"_animationName": "normal",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "ac9a69d6-8ef7-4ae8-b84a-73f1ffbfeb1c#3592528d-2b01-442c-ad9e-c701ab6dd067",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "ac9a69d6-8ef7-4ae8-b84a-73f1ffbfeb1c"
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "7ac0160b-8705-4710-b65d-3bab72310bbc"
},
"_N$dragonAtlasAsset": {
"__uuid__": "3592528d-2b01-442c-ad9e-c701ab6dd067"
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 1,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "b5ZWY5+bFE3YNqJ+CrU6nq"
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "4ejxxGDy5PPaBb6LVFKpsc"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "305Bnt78BML5iK0PU65G5T",
"sync": false
},
{
"__type__": "cc.Node",
"_name": "goodjob",
"_name": "markPoint",
"_objFlags": 0,
"_parent": {
"__id__": 2
"__id__": 10
},
"_children": [],
"_active": false,
"_components": [
{
"__id__": 9
"__id__": 34
}
],
"_prefab": null,
"_prefab": {
"__id__": 35
},
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
......@@ -396,8 +1384,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 700,
"height": 700
"width": 15,
"height": 15
},
"_anchorPoint": {
"__type__": "cc.Vec2",
......@@ -431,14 +1419,14 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "f23hV9mnBBYZ1OXVQg3VZs"
"_id": "6ad+N+W5hJPL901Y2uUpbz"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
"__id__": 33
},
"_enabled": true,
"_materials": [
......@@ -446,32 +1434,83 @@
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_armatureName": "armatureName",
"_animationName": "newAnimation",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "9d28773b-d69f-4fc8-b675-16fde99a4712#f615b7c8-a715-4f8d-88f6-c6b0765ede74",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "9d28773b-d69f-4fc8-b675-16fde99a4712"
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "3fc25a16-8cbc-4cdd-99a2-5251bb1dcf5d"
},
"_N$dragonAtlasAsset": {
"__uuid__": "f615b7c8-a715-4f8d-88f6-c6b0765ede74"
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 1,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "66t644bDFDb73XispqPIHj"
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "3crB2UVtJDL5iR88caaxi5"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "359axb3wRFnpR16d4pl6Xc",
"sync": false
},
{
"__type__": "28e11HTXPtGa7wWg93PflND",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"_id": "42XWQfk9tE94NY0efe9K5z"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 10
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 17,
"_left": 0,
"_right": 0,
"_top": 100,
"_bottom": 100,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "55RxCZdFRM57g/M/UMg8IZ"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 10
},
"asset": {
"__uuid__": "a1cb871b-6ef5-410e-802f-f3a1c2d185e9"
},
"fileId": "",
"sync": false
},
{
"__type__": "cc.Node",
......@@ -482,13 +1521,13 @@
},
"_children": [
{
"__id__": 11
"__id__": 40
},
{
"__id__": 26
"__id__": 55
},
{
"__id__": 29
"__id__": 58
}
],
"_active": false,
......@@ -546,29 +1585,29 @@
"_name": "img",
"_objFlags": 0,
"_parent": {
"__id__": 10
"__id__": 39
},
"_children": [
{
"__id__": 12
"__id__": 41
},
{
"__id__": 14
"__id__": 43
},
{
"__id__": 16
"__id__": 45
},
{
"__id__": 18
"__id__": 47
},
{
"__id__": 20
"__id__": 49
},
{
"__id__": 22
"__id__": 51
},
{
"__id__": 24
"__id__": 53
}
],
"_active": true,
......@@ -626,13 +1665,13 @@
"_name": "go_1",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 13
"__id__": 42
}
],
"_prefab": null,
......@@ -688,7 +1727,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 12
"__id__": 41
},
"_enabled": true,
"_materials": [],
......@@ -716,13 +1755,13 @@
"_name": "black",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 15
"__id__": 44
}
],
"_prefab": null,
......@@ -778,7 +1817,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 14
"__id__": 43
},
"_enabled": true,
"_materials": [],
......@@ -806,13 +1845,13 @@
"_name": "go_3",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 17
"__id__": 46
}
],
"_prefab": null,
......@@ -868,7 +1907,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 16
"__id__": 45
},
"_enabled": true,
"_materials": [],
......@@ -896,13 +1935,13 @@
"_name": "go_2",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 19
"__id__": 48
}
],
"_prefab": null,
......@@ -958,7 +1997,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 18
"__id__": 47
},
"_enabled": true,
"_materials": [],
......@@ -986,13 +2025,13 @@
"_name": "start_title",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 21
"__id__": 50
}
],
"_prefab": null,
......@@ -1048,7 +2087,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 20
"__id__": 49
},
"_enabled": true,
"_materials": [],
......@@ -1076,13 +2115,13 @@
"_name": "go_0",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 23
"__id__": 52
}
],
"_prefab": null,
......@@ -1138,7 +2177,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 22
"__id__": 51
},
"_enabled": true,
"_materials": [],
......@@ -1166,13 +2205,13 @@
"_name": "light",
"_objFlags": 0,
"_parent": {
"__id__": 11
"__id__": 40
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 25
"__id__": 54
}
],
"_prefab": null,
......@@ -1228,7 +2267,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
"__id__": 53
},
"_enabled": true,
"_materials": [],
......@@ -1256,11 +2295,11 @@
"_name": "font",
"_objFlags": 0,
"_parent": {
"__id__": 10
"__id__": 39
},
"_children": [
{
"__id__": 27
"__id__": 56
}
],
"_active": true,
......@@ -1318,13 +2357,13 @@
"_name": "GOTHICB_1",
"_objFlags": 0,
"_parent": {
"__id__": 26
"__id__": 55
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 28
"__id__": 57
}
],
"_prefab": null,
......@@ -1380,7 +2419,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 27
"__id__": 56
},
"_enabled": true,
"_materials": [
......@@ -1415,17 +2454,17 @@
"_name": "audio",
"_objFlags": 0,
"_parent": {
"__id__": 10
"__id__": 39
},
"_children": [
{
"__id__": 30
"__id__": 59
},
{
"__id__": 32
"__id__": 61
},
{
"__id__": 34
"__id__": 63
}
],
"_active": true,
......@@ -1483,13 +2522,13 @@
"_name": "goodjob",
"_objFlags": 0,
"_parent": {
"__id__": 29
"__id__": 58
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 31
"__id__": 60
}
],
"_prefab": null,
......@@ -1545,7 +2584,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 30
"__id__": 59
},
"_enabled": true,
"_clip": {
......@@ -1564,13 +2603,13 @@
"_name": "ready",
"_objFlags": 0,
"_parent": {
"__id__": 29
"__id__": 58
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 33
"__id__": 62
}
],
"_prefab": null,
......@@ -1626,7 +2665,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 32
"__id__": 61
},
"_enabled": true,
"_clip": {
......@@ -1645,13 +2684,13 @@
"_name": "go",
"_objFlags": 0,
"_parent": {
"__id__": 29
"__id__": 58
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 35
"__id__": 64
}
],
"_prefab": null,
......@@ -1707,7 +2746,7 @@
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 34
"__id__": 63
},
"_enabled": true,
"_clip": {
......@@ -1775,6 +2814,9 @@
"_enabled": true,
"baseWidth": 1280,
"baseHeight": 940,
"_id": "bf/vzovXRMI6/uFQ1Gtl23"
"videoControlBar": {
"__id__": 10
},
"_id": "7akLvWOt5IlbhsZJIcu0P1"
}
]
\ No newline at end of file
......@@ -6,7 +6,28 @@
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
// import { getSprNode } from "./util";
import { onHomeworkFinish, getSprNode, playAudioByUrl, getScaleRateBy2Node, localPosTolocalPos, randomSortByArr, loadDragonBones, playAudio, showTrebleFirework, delayCall, removeFromArr, showBtnAnima, asyncDelay, jellyShake, showLog, formatTime, getSpriteFrimeByUrl, RandomInt, exchangeNodePos, getSprNodeByUrl } from "../script/util";
import {
onHomeworkFinish,
getSprNode,
playAudioByUrl,
getScaleRateBy2Node,
localPosTolocalPos,
randomSortByArr,
loadDragonBones,
playAudio,
showTrebleFirework,
delayCall,
removeFromArr,
showBtnAnima,
asyncDelay,
jellyShake,
showLog,
formatTime,
getSpriteFrimeByUrl,
RandomInt,
exchangeNodePos,
getSprNodeByUrl,
} from "../script/util";
cc.Class({
extends: cc.Component,
......@@ -14,11 +35,15 @@ cc.Class({
properties: {
baseWidth: {
default: 1280,
type: cc.Integer
type: cc.Integer,
},
baseHeight: {
default: 940,
type: cc.Integer
type: cc.Integer,
},
videoControlBar: {
default: null,
type: cc.Node
}
},
......@@ -34,8 +59,6 @@ cc.Class({
this._animaResList = [];
},
_designSize: null,
_frameSize: null,
_mapScaleMin: null,
......@@ -43,15 +66,16 @@ cc.Class({
_cocosScale: null,
canvas: null,
initSize() {
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let screen_size = cc.view.getFrameSize().width / cc.view.getFrameSize().height
let design_size = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height
let f = screen_size >= design_size
let screen_size =
cc.view.getFrameSize().width / cc.view.getFrameSize().height;
let design_size =
cc.Canvas.instance.designResolution.width /
cc.Canvas.instance.designResolution.height;
let f = screen_size >= design_size;
cc.Canvas.instance.fitHeight = f
cc.Canvas.instance.fitWidth = !f
cc.Canvas.instance.fitHeight = f;
cc.Canvas.instance.fitWidth = !f;
const frameSize = cc.view.getFrameSize();
this._frameSize = frameSize;
......@@ -67,8 +91,7 @@ cc.Class({
this._mapScaleMin = Math.min(sx, sy) * this._cocosScale;
this._mapScaleMax = Math.max(sx, sy) * this._cocosScale;
this.canvas = cc.find('Canvas');
this.canvas = cc.find("Canvas");
// cc.log('cc.Canvas: ', cc.Canvas);
},
......@@ -76,8 +99,7 @@ cc.Class({
isTeacher: null,
serverAllUser: null,
start() {
const nextBtn = cc.find('middleLayer/BtnRight');
const nextBtn = cc.find("middleLayer/BtnRight");
if (nextBtn) {
nextBtn.active = false;
}
......@@ -87,25 +109,23 @@ cc.Class({
getData = window.courseware.getData;
}
getData((data, aspect) => {
if (window['air']?.airClassInfo?.user?.classRole == 'tea') {
if (window["air"]?.airClassInfo?.user?.classRole == "tea") {
this.isTeacher = true;
}
if (aspect) {
console.log('aspect : ', aspect);
console.log("aspect : ", aspect);
this.serverAllUser = aspect.all_user;
this.initPageData(aspect);
}
// this.initPageData({});
this.data = data || this.getDefaultData();
console.log('data:', this.data);
console.log('dataStr:', JSON.stringify(this.data));
console.log("data:", this.data);
console.log("dataStr:", JSON.stringify(this.data));
this.preloadItem()
})
this.preloadItem();
});
},
// 用于存储公共数据 当翻页时清空
......@@ -117,16 +137,12 @@ cc.Class({
} else {
this.pageData = JSON.parse(pageDataStr);
}
console.log('this.pageData: ', this.pageData);
console.log("this.pageData: ", this.pageData);
},
setPageData(key, value, isSend = true) {
if (this.pageData) {
console.log('this.pageData: ', this.pageData);
console.log("this.pageData: ", this.pageData);
this.pageData[key] = value;
if (isSend) {
......@@ -142,13 +158,12 @@ cc.Class({
},
sendPageData() {
const data = this.pageData;
if (window && window.courseware) {
let storePageAspect = window.courseware.storePageAspect;
if (storePageAspect) {
storePageAspect(data);
console.log('storePageAspect : ', data);
console.log("storePageAspect : ", data);
}
}
},
......@@ -165,13 +180,13 @@ cc.Class({
getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'ak_08');
window.courseware.getData(func, "ak_08");
return;
}
const middleLayer = cc.find('middleLayer');
const middleLayer = cc.find("middleLayer");
if (middleLayer) {
const middleLayerComponent = middleLayer.getComponent('middleLayer');
const middleLayerComponent = middleLayer.getComponent("middleLayer");
middleLayerComponent.getData(func);
return;
}
......@@ -180,13 +195,74 @@ cc.Class({
},
getDefaultData() {
return {"quesArr":[{"itemType":"jump","bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/50fe1264135d63c082fa6fb9b7c9dbc2.png","rect":{"x":10.61,"y":0,"width":1201.78,"height":676}},"hotZoneItemArr":[{"id":"1666086880680","index":0,"itemType":"rect","fontScale":0.95546875,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.95546875,"dragDot":{"x":611.5,"y":337.9992270947921},"gIdx":"0","posX":344.2576312800029,"posY":542.6844069496866,"rect":{"x":204.9,"y":261.35,"width":266.77,"height":408.16}}],"ques_start":"0","ques_end":"3"},{"itemType":"jump","ques_start":"3","ques_end":"7","bgItem":{"url":"http://staging-teach.cdn.ireadabc.com/50fe1264135d63c082fa6fb9b7c9dbc2.png","rect":{"x":10.61,"y":0,"width":1201.78,"height":676}},"hotZoneItemArr":[{"id":"1666160708755","index":0,"itemType":"rect","fontScale":0.95546875,"imgScale":1,"imgSizeW":0,"imgSizeH":0,"mapScale":0.95546875,"dragDot":{"x":611.5,"y":338.0006033081422},"gIdx":"0","posX":821.5,"posY":559,"rect":{"x":653.46,"y":304.59,"width":307.57,"height":353.75}}]}],"video_url":"http://staging-teach.cdn.ireadabc.com/6c03006397a8309aa510210322ae1572.mp4","videoType":"1920_1080"}
return {
// jumpTime: '4',
// isDebug: true,
quesArr: [
{
itemType: "jump",
bgItem: {
url: "http://staging-teach.cdn.ireadabc.com/50fe1264135d63c082fa6fb9b7c9dbc2.png",
rect: { x: 10.61, y: 0, width: 1201.78, height: 676 },
},
hotZoneItemArr: [
{
id: "1666086880680",
index: 0,
itemType: "rect",
fontScale: 0.95546875,
imgScale: 1,
imgSizeW: 0,
imgSizeH: 0,
mapScale: 0.95546875,
dragDot: { x: 611.5, y: 337.9992270947921 },
gIdx: "0",
posX: 344.2576312800029,
posY: 542.6844069496866,
rect: { x: 204.9, y: 261.35, width: 266.77, height: 408.16 },
},
],
ques_start: "0",
ques_end: "3",
},
{
itemType: "jump",
ques_start: "3",
ques_end: "7",
bgItem: {
url: "http://staging-teach.cdn.ireadabc.com/50fe1264135d63c082fa6fb9b7c9dbc2.png",
rect: { x: 10.61, y: 0, width: 1201.78, height: 676 },
},
hotZoneItemArr: [
{
id: "1666160708755",
index: 0,
itemType: "rect",
fontScale: 0.95546875,
imgScale: 1,
imgSizeW: 0,
imgSizeH: 0,
mapScale: 0.95546875,
dragDot: { x: 611.5, y: 338.0006033081422 },
gIdx: "0",
posX: 821.5,
posY: 559,
rect: { x: 653.46, y: 304.59, width: 307.57, height: 353.75 },
},
],
},
],
video_url:
"http://staging-teach.cdn.ireadabc.com/6c03006397a8309aa510210322ae1572.mp4",
videoType: "1920_1080",
};
},
preload() {
const preloadArr = this._imageResList.concat(this._audioResList).concat(this._animaResList);
console.log('preloadArr: ', JSON.stringify( preloadArr) );
const preloadArr = this._imageResList
.concat(this._audioResList)
.concat(this._animaResList);
console.log("preloadArr: ", JSON.stringify(preloadArr));
cc.assetManager.loadAny(preloadArr, null, null, (err, data) => {
// console.log(' preload data, ', data);
......@@ -200,7 +276,6 @@ cc.Class({
},
addPreloadImage() {
const quesArr = this.data.quesArr;
if (!quesArr || quesArr.length == 0) {
return;
......@@ -213,21 +288,17 @@ cc.Class({
this._imageResList.push({ url: item.bgItem.url });
}
if (!item.hotZoneItemArr) {
continue;
}
item.hotZoneItemArr.forEach((value) => {
this._imageResList.push({ url: value.pic_url | '' });
this._imageResList.push({ url: value.pic2_url | '' });
})
this._imageResList.push({ url: value.pic_url | "" });
this._imageResList.push({ url: value.pic2_url | "" });
});
}
},
addPreloadAudio(callback) {
const url1 = this.data.video_url;
if (!url1) {
callback();
......@@ -235,13 +306,12 @@ cc.Class({
}
this.getVideoUrl((url) => {
console.log('url: ', url);
console.log("url: ", url);
this.data.video_url = url;
this._audioResList.push({ url: url || '' });
this._audioResList.push({ url: url || "" });
callback();
})
});
},
addPreloadAnima() {
......@@ -257,11 +327,8 @@ cc.Class({
// })
},
loadEnd(cb) {
console.log(' in loadEnd ')
console.log(" in loadEnd ");
if (this.isDestroy) {
return;
}
......@@ -274,50 +341,38 @@ cc.Class({
// cb();
// return;
this.initData();
this.initMask();
this.getState(() => {
if (window && window["air"]) {
window["air"].hideAirClassLoading();
}
this.initView();
this.initListener();
cb();
})
});
},
isFirst : null,
isLast : null,
playTimes : null,
jumpData : null,
isFirst: null,
isLast: null,
playTimes: null,
jumpData: null,
getState(cb) {
this.isFirst = this.checkIsFirst(); // data.first; //this.checkIsFirst();
this.isLast = this.checkIsLast(); // data.last // this.checkIsLast();
this.playTimes = this.checkPlayTimes(); // data.playTime// this.checkPlayTimes();
this.jumpData = this.getJumpData(); //data.saveData // this.getJumpData();
cb()
cb();
return;
console.log(' in getState 1');
console.log(" in getState 1");
callMiddleLayerFunction('PSQS_get_course_info', {}, (data) => {
console.log(' in getState 2');
callMiddleLayerFunction("PSQS_get_course_info", {}, (data) => {
console.log(" in getState 2");
this.isFirst = this.checkIsFirst(); // data.first; //this.checkIsFirst();
this.isLast = this.checkIsLast(); // data.last // this.checkIsLast();
......@@ -329,30 +384,28 @@ cc.Class({
}
cb && cb();
})
});
},
checkIsFirst() {
checkIsFirst() {
return false;
},
},
checkIsLast() {
checkIsLast() {
return false;
},
},
checkPlayTimes() {
checkPlayTimes() {
return 1;
},
},
getJumpData() {
return //{step: 1};
},
getJumpData() {
return; //{step: 1};
},
maskSpr: null,
initMask() {
const mask = getSprNode('black');
maskSpr: null,
initMask() {
const mask = getSprNode("black");
const sx = this.canvas.width / mask.width;
const sy = this.canvas.height / mask.height;
mask.scaleX = sx;
......@@ -360,10 +413,7 @@ initMask() {
mask.opacity = 255;
this.canvas.addChild(mask, 21);
this.maskSpr = mask;
},
},
initMusic() {
cc.assetManager.loadRemote(this.data.bg_audio_url, (err, clip) => {
......@@ -372,7 +422,6 @@ initMask() {
});
},
isDebug: null,
treeType: null,
......@@ -396,88 +445,79 @@ initMask() {
isLocal: null,
initData() {
this.isLocal = true;
this.quesIndex = 0;
this.curEndTime = -1;
this.dragEndRectArr = [];
if (this.data.jumpTime) {
this.jumpTime = Number(this.data.jumpTime);
}
this.initAudioEffect();
},
resetQuesIndex() {
setProgressBarMarkPoints() {
let points = [];
for(let i=0;i<this.data.quesArr.length;i++) {
const endTime = Number(this.data.quesArr[i].ques_end)
points.push(endTime / this.videoDuration)
}
this.videoControlBar.emit("set_mark_points", points)
},
resetQuesIndex(jumpTime) {
this.quesIndex = -1;
for (let i=0; i<this.data.quesArr.length; i++) {
const checkTime = this.data.quesArr[i].ques_start;
if (Number(this.jumpTime) >= Number(checkTime)) {
for (let i = 0; i < this.data.quesArr.length; i++) {
const startTime = this.data.quesArr[i].ques_start;
const endTime = this.data.quesArr[i].ques_end;
if (Number(jumpTime) >= Number(startTime) && Number(jumpTime) < Number(endTime)) {
this.quesIndex = i;
} else {
return;
// console.log("重定位题号:",this.quesIndex)
}
}
},
audioGoodjob: null,
audioTryagain: null,
readyClip: null,
goClip: null,
goodjobClip: null,
initAudioEffect() {
const audioNode = cc.find('Canvas/res/audio');
const audioNode = cc.find("Canvas/res/audio");
const getAudioByResName = (resName) => {
return audioNode.getChildByName(resName).getComponent(cc.AudioSource).clip;
}
return audioNode.getChildByName(resName).getComponent(cc.AudioSource)
.clip;
};
// this.audioGoodjob = getAudioByResName('goodjob');
// this.audioTryagain = getAudioByResName('tryagain');
this.readyClip = getAudioByResName('ready');
this.goClip = getAudioByResName('go');
this.goodjobClip = getAudioByResName('goodjob');
this.readyClip = getAudioByResName("ready");
this.goClip = getAudioByResName("go");
this.goodjobClip = getAudioByResName("goodjob");
},
sendServerEvent(key, data) {
const c = window.courseware;
if (c) {
c.sendEvent(key, data);
}
},
addServerListener() {
console.log(' in addServerListener');
console.log(" in addServerListener");
const c = window.courseware;
this.loadEnd();
if (!c) {
return;
}
if (!window.air) {
console.log(' window air err !!!!!!!!')
console.log(" window air err !!!!!!!!");
return;
}
......@@ -487,60 +527,44 @@ initMask() {
this.loadEnd(() => {
next();
});
}
};
},
initView() {
console.log( ' in initView')
console.log(" in initView");
this.hideMask();
this.initVideo();
this.initHand();
this.initHotZone();
},
initHand() {
this.hand = cc.find("Canvas/hand");
this.hand.active = false;
},
initStartView() {
this.showStartLight();
if (this.playTimes > 0) {
this.showStartTitleGo();
} else {
this.showStartTitleReady();
}
},
lightBg: null,
lightLeft: null,
lightRight: null,
showStartLight() {
},
const lightBg = getSprNode('black');
lightBg: null,
lightLeft: null,
lightRight: null,
showStartLight() {
const lightBg = getSprNode("black");
lightBg.scaleX = this.canvas.width / lightBg.width;
lightBg.scaleY = this.canvas.height / lightBg.height;
lightBg.opacity = 180;
this.canvas.addChild(lightBg, 10);
const lightLeft = getSprNode('light');
const lightLeft = getSprNode("light");
lightLeft.anchorY = 0.9;
lightLeft.x = -this.canvas.width / 2;
lightLeft.y = this.canvas.height / 2;
......@@ -550,13 +574,11 @@ showStartLight() {
lightLeft.rotation = 45;
lightLeft.opacity = 0;
cc.tween(lightLeft)
.to(1, {rotation: -45}, {easing: "cubicOut"})
.start();
cc.tween(lightLeft)
.to(0.5, {opacity: 255})
.to(1, { rotation: -45 }, { easing: "cubicOut" })
.start();
cc.tween(lightLeft).to(0.5, { opacity: 255 }).start();
const lightRight = getSprNode('light');
const lightRight = getSprNode("light");
lightRight.anchorY = 0.9;
lightRight.x = this.canvas.width / 2;
lightRight.y = this.canvas.height / 2;
......@@ -566,23 +588,18 @@ showStartLight() {
lightRight.rotation = -45;
lightRight.opacity = 0;
cc.tween(lightRight)
.to(1, {rotation: 45}, {easing: "cubicOut"})
.start();
cc.tween(lightRight)
.to(0.5, {opacity: 255})
.to(1, { rotation: 45 }, { easing: "cubicOut" })
.start();
cc.tween(lightRight).to(0.5, { opacity: 255 }).start();
this.lightBg = lightBg;
this.lightLeft = lightLeft;
this.lightRight = lightRight;
},
},
title: null,
showStartTitleReady() {
const title = getSprNode('start_title');
const title = getSprNode("start_title");
title.scale = this._mapScaleMin;
title.y = this.canvas.height / 2 + title.height * title.scaleY;
title.parent = this.canvas;
......@@ -591,29 +608,26 @@ showStartLight() {
cc.tween(title)
.delay(0.3)
.call(() => {
playAudio(this.readyClip, (() => {
playAudio(this.readyClip, () => {
this.startAudioEnd();
}));
});
})
.to(1.5, {y: 0}, {easing: "elasticOut"})
.to(1.5, { y: 0 }, { easing: "elasticOut" })
.start();
this.title = title
this.title = title;
},
async showStartTitleGo() {
const title = new cc.Node();
title.parent = this.canvas;
title.zIndex = 11;
title.scale = this._mapScaleMin;
this.title = title
this.title = title;
playAudio(this.goClip, (() => {
playAudio(this.goClip, () => {
this.startAudioEnd();
}));
});
const popNum = (name, time = 1) => {
const sprNode = getSprNode(name);
......@@ -622,28 +636,26 @@ showStartLight() {
sprNode.opacity = 0;
cc.tween(sprNode)
.to(time/10, {opacity: 255})
.to(time / 10, { opacity: 255 })
.start();
cc.tween(sprNode)
.to(0.8 * time, {scale: this._mapScaleMin}, {easing: 'elasticOut'})
.to(0.8 * time, { scale: this._mapScaleMin }, { easing: "elasticOut" })
.delay(0 * time)
.to(0.2 * time, {opacity: 0})
.to(0.2 * time, { opacity: 0 })
.start();
}
};
await asyncDelay(2.2);
popNum('go_1', 0.7);
popNum("go_1", 0.7);
await asyncDelay(0.7);
popNum('go_2', 0.7);
popNum("go_2", 0.7);
await asyncDelay(0.7);
popNum('go_3', 0.7);
popNum("go_3", 0.7);
await asyncDelay(0.7);
popNum('go_0');
popNum("go_0");
await asyncDelay(1);
},
isDestroy: null,
......@@ -655,56 +667,49 @@ showStartLight() {
},
async hideStartView() {
const hideSpr = (sprNode, cb=null) => {
const hideSpr = (sprNode, cb = null) => {
cc.tween(sprNode)
.to(0.3, {opacity: 0})
.to(0.3, { opacity: 0 })
.call(() => {
sprNode.active = false;
cb && cb();
})
.start();
}
};
hideSpr(this.lightLeft);
hideSpr(this.lightRight);
hideSpr(this.title);
await asyncDelay(0.2)
await asyncDelay(0.2);
hideSpr(this.lightBg, () => {
if (this.isDestroy) {
return;
}
this.startQuesVideo();
});
},
serverStartTest(text) {
console.log(' in serverStartTest: ', text);
const cw = window?.courseware
console.log(" in serverStartTest: ", text);
const cw = window?.courseware;
if (cw) {
if (this.curQues.isKK && this.curQues.KKText) {
cw.startTest(text, {"pronounce": this.curQues.KKText});
cw.startTest(text, { pronounce: this.curQues.KKText });
} else {
cw.startTest(text);
}
}
this.addMask();
},
hideMask(cb = null) {
const mask = this.maskSpr;
mask.opacity = 255;
cc.tween(mask)
.to(0.2, {opacity: 0}, {easing: "sineOut"})
.to(0.2, { opacity: 0 }, { easing: "sineOut" })
.call(() => {
// mask.active = false;
cb && cb();
......@@ -713,29 +718,22 @@ showStartLight() {
},
serverStopTest(item) {
const cw = window?.courseware
const cw = window?.courseware;
if (cw) {
cw.stopTest(data => {
console.log('stopTest data: ', data);
cw.stopTest((data) => {
console.log("stopTest data: ", data);
if (data && typeof (data) == 'string') {
if (data && typeof data == "string") {
console.log(JSON.parse(data));
data = JSON.parse(data)
data = JSON.parse(data);
}
this.setRecordItemAudio(data, item);
});
}
},
setRecordItemAudio(data, item) {
if (!data) {
return;
}
......@@ -743,23 +741,21 @@ showStartLight() {
const audioUrl = data.audioUrl;
item.audioUrl = audioUrl;
const overall = data.result?.overall;
const integrity = data.result?.integrity;
const score = integrity * 0.1 + overall * 0.9; //data.result?.overall;
// item.score = score;
console.log('overall is : ', overall);
console.log('integrity is : ', integrity);
console.log('score is : ', score);
console.log("overall is : ", overall);
console.log("integrity is : ", integrity);
console.log("score is : ", score);
item.score = score;
console.log(' score: ', score);
console.log(" score: ", score);
this.hideMask();
this.video.pause();
this.videoControlBar.emit("update_video_status", 0);
this.wrongTimes++;
......@@ -772,16 +768,9 @@ showStartLight() {
this.startWrongVideo();
}
}
},
initVideo() {
// this.initQuesList();
this.initCurQues();
......@@ -789,7 +778,6 @@ showStartLight() {
this.initVideoRemote();
// })
// this.checkStart();
},
getVideoUrl(callback) {
......@@ -797,20 +785,18 @@ showStartLight() {
const url2 = url1.replace(/.mp4$/g, "_m.mp4");
this.httpHeadCall(url2, (success) => {
if (success) {
console.log('return url2: ', url2);
console.log("return url2: ", url2);
callback(url2);
} else {
console.log('return url1: ', url1);
console.log("return url1: ", url1);
callback(url1);
}
})
});
},
checkStart() {
console.log(' in checkStart ..', this.curQues);
console.log(" in checkStart ..", this.curQues);
const data = this.curQues;
const videoNode = data?.videoObj?.ques_video;
......@@ -819,27 +805,27 @@ showStartLight() {
} else {
delayCall(0.2, () => {
this.checkStart();
})
});
}
},
gameEnd() {
console.log(' in gameEnd');
console.log(" in gameEnd");
this.showRestart();
const data = this.getHomeworkFinishData();
console.log("homeworkData: ", JSON.stringify(data));
onHomeworkFinish(data)
onHomeworkFinish(data);
},
getHomeworkFinishData() {
const arr = this.data.quesArr;
const result = []
for (let i=0; i<arr.length; i++) {
const result = [];
for (let i = 0; i < arr.length; i++) {
const oneData = {};
oneData.type = arr[i].itemType;
if (oneData.type == 'sound') {
if (oneData.type == "sound") {
oneData.word = arr[i].text;
oneData.audio_url = arr[i].audioUrl;
oneData.score = arr[i].score;
......@@ -850,9 +836,18 @@ showStartLight() {
result.push(oneData);
}
return {result};
return { result };
},
getCurrentQuesIndexByTime(curretnTime) {
let qIndex = -1;
for(let i=0; i<this.data.quesArr.length; i++) {
if(curretnTime>=Number(this.data.quesArr[i].ques_end)) {
qIndex = i;
}
}
return qIndex;
},
checkNextQues() {
this.quesIndex++;
......@@ -865,12 +860,11 @@ showStartLight() {
},
startQuesVideo(currentTime = null) {
console.log(' in startQuesVideo')
console.log(" in startQuesVideo");
this.wrongTimes = 0;
const video = this.video;
video.node.name = 'ques_video';
video.node.name = "ques_video";
console.log("this.curQues: ", this.curQues);
......@@ -880,9 +874,7 @@ showStartLight() {
video.currentTime = Number(this.curQues.ques_start);
}
if (this.playTimes > 0) {
if (this.curQues) {
this.curEndTime = Number(this.curQues.ques_end);
}
......@@ -890,13 +882,14 @@ showStartLight() {
delayCall(0.01, () => {
video.play();
})
this.videoControlBar.emit("update_video_status", 1);
});
},
isWaitingUserAction: false,
startWaitVideo() {
console.log(' in startWaitVideo ')
console.log(" in startWaitVideo ");
this.isWaitingUserAction = true;
this.curQues.hotZoneBg.active = true;
this.hand.active = true;
......@@ -912,40 +905,46 @@ showStartLight() {
// this.curVideo = video;
// this.resetVideoPos(videoNode);
const video = this.video;
video.node.name = 'wait_video';
video.node.name = "wait_video";
video.currentTime = Number(this.curQues.wait_start);
this.curEndTime = Number(this.curQues.wait_end);
delayCall(0.01, () => {
video.play();
})
this.videoControlBar.emit("update_video_status", 1);
});
if (this.curQues.itemType == 'sound') {
if (this.curQues.itemType == "sound") {
this.serverStartTest(this.curQues.text);
delayCall(3, () => {
this.serverStopTest(this.curQues);
})
});
} else {
this.curQues.hotZoneBg.active = true;
}
},
continueWaitVideo() {
console.log(' in continueWaitVideo ')
hideWaitingVideo() {
console.log(" in hiddeWaitVideo ");
this.isWaitingUserAction = false;
this.curQues.hotZoneBg.active = false;
this.hand.active = false;
},
continueWaitVideo() {
console.log(" in continueWaitVideo ");
this.video.currentTime = Number(this.curQues.wait_start);
this.curEndTime = Number(this.curQues.wait_end);
delayCall(0.01, () => {
this.video.play();
})
this.videoControlBar.emit("update_video_status", 1);
});
},
startRightVideo() {
console.log(' in startRightVideo ')
console.log(" in startRightVideo ");
// const videoNode = this.curQues?.videoObj?.right_video;
// const video = videoNode.getComponent(cc.VideoPlayer);
......@@ -955,20 +954,19 @@ showStartLight() {
// this.curVideo = video;
// this.resetVideoPos(videoNode);
const video = this.video;
video.node.name = 'right_video';
video.node.name = "right_video";
video.currentTime = Number(this.curQues.right_start);
this.curEndTime = Number(this.curQues.right_end);
delayCall(0.01, () => {
video.play();
})
this.videoControlBar.emit("update_video_status", 1);
});
},
startWrongVideo() {
console.log(' in startWrongVideo ')
console.log(" in startWrongVideo ");
// const videoNode = this.curQues?.videoObj?.wrong_video;
// const video = videoNode.getComponent(cc.VideoPlayer);
......@@ -979,7 +977,7 @@ showStartLight() {
// this.resetVideoPos(videoNode);
const video = this.video;
video.node.name = 'wrong_video';
video.node.name = "wrong_video";
if (this.wrongStartTime && this.wrongEndTime) {
video.currentTime = this.wrongStartTime;
......@@ -991,11 +989,12 @@ showStartLight() {
delayCall(0.01, () => {
video.play();
})
this.videoControlBar.emit("update_video_status", 1);
});
},
startEndVideo() {
console.log(' in startEndVideo ')
console.log(" in startEndVideo ");
// const videoNode = this.curQues?.videoObj?.end_video;
// const video = videoNode.getComponent(cc.VideoPlayer);
......@@ -1010,14 +1009,14 @@ showStartLight() {
return;
}
const video = this.video;
video.node.name = 'end_video';
video.node.name = "end_video";
video.currentTime = Number(this.curQues.end_start);
this.curEndTime = Number(this.curQues.end_end);
delayCall(0.01, () => {
video.play();
})
this.videoControlBar.emit("update_video_status", 1);
});
},
resetVideoPos(videoNode) {
......@@ -1033,31 +1032,29 @@ showStartLight() {
},
initCurQues() {
if(this.quesIndex >=0) {
this.curQues = this.data.quesArr[this.quesIndex];
console.log('this.data.quesArr: ', this.data.quesArr);
console.log("curQues: ", this.curQues);
} else {
console.log('题目序号不能为负数');
}
},
videoDuration: null,
initVideoRemote() {
const url = this.data.video_url;
console.log(' in initVideoRemote url: ', url)
console.log(" in initVideoRemote url: ", url);
const videoSizeW = 1920;
const videoSizeH = 1080;
const videoRemoteNode = new cc.Node();
videoRemoteNode.width = videoSizeW
videoRemoteNode.height = videoSizeH
videoRemoteNode.width = videoSizeW;
videoRemoteNode.height = videoSizeH;
videoRemoteNode.parent = this.canvas;
// videoRemoteNode.y = -this.canvas.height * 1.5;
videoRemoteNode.scale = this.canvas.height / videoSizeH;
const video = videoRemoteNode.addComponent(cc.VideoPlayer);
......@@ -1069,60 +1066,51 @@ showStartLight() {
this.video = video;
video.node.on('meta-loaded', (e) => {
console.log('meta-loaded e:', e);
})
video.node.on('ready-to-play', async (e) => {
console.log('e: ', e);
video.node.on("meta-loaded", (e) => {
console.log("meta-loaded e:", e);
});
video.node.on("ready-to-play", async (e) => {
console.log("e: ", e);
if (this.isDestroy) {
return;
}
video.play();
checkIsPlaying();
})
});
const checkIsPlaying = () => {
delayCall(0.05, () => {
if (video.currentTime > 0) {
video.node.isLoadEnd = true;
video.pause();
this.videoLoadEnd();
// this.startQuesVideo();
} else {
checkIsPlaying();
}
})
}
});
};
video.node.on('completed', () => {
console.log(' in completed!!!!');
video.node.on("completed", () => {
console.log(" in completed!!!!");
if (this.isLast && this.playTimes > 0) {
this.showGoodjob();
} else {
this.showMask(() => {
if (!this.isLocal) {
callMiddleLayerFunction('PSQS_play_animate_over', null, () => {})
callMiddleLayerFunction("PSQS_play_animate_over", null, () => {});
}
})
});
}
// this.curVideoPlayEnd();
})
});
return video.node;
},
showGoodjob() {
......@@ -1132,22 +1120,17 @@ showStartLight() {
goodjob.scale = this._mapScaleMin;
const dragonDisplay = goodjob.getComponent(dragonBones.ArmatureDisplay);
dragonDisplay.playAnimation('newAnimation', 1);
dragonDisplay.playAnimation("newAnimation", 1);
playAudio(this.goodjobClip, async () => {
await asyncDelay(3);
console.log(' end .....');
console.log(" end .....");
this.showMask(() => {
if (!this.isLocal) {
callMiddleLayerFunction('PSQS_play_animate_over', null, () => {})
callMiddleLayerFunction("PSQS_play_animate_over", null, () => {});
}
})
});
});
},
getColorRect(w, h) {
......@@ -1160,16 +1143,16 @@ showStartLight() {
},
videoLoadEnd() {
this.videoDuration = this.video.getDuration();
// 时长获取到以后 可以计算题目点
this.setProgressBarMarkPoints();
if (this.jumpData) {
this.setJumpTime();
}
if (this.jumpTime) {
this.resetQuesIndex();
this.resetQuesIndex(this.jumpTime);
this.initCurQues();
} else if (this.isFirst) {
this.initStartView();
return;
......@@ -1179,13 +1162,12 @@ showStartLight() {
},
setJumpTime() {
let isFind = false;
for (let i=0; i<this.data.quesArr.length; i++) {
for (let i = 0; i < this.data.quesArr.length; i++) {
const id = i;
if (id == this.jumpData.step) {
const quesData = this.data.quesArr[i];
this.jumpTime = Number( quesData.ques_start );
this.jumpTime = Number(quesData.ques_start);
isFind = true;
break;
......@@ -1196,21 +1178,13 @@ showStartLight() {
const lastQuesData = this.data.quesArr[this.data.quesArr.length - 1];
this.jumpTime = lastQuesData.ques_end;
}
},
curVideoPlayEnd() {
if (this.playTimes == 0) {
return;
}
switch (this.video.node.name) {
case "ques_video":
this.startWaitVideo();
......@@ -1223,7 +1197,7 @@ showStartLight() {
// this.checkNextQues();
break;
case "wrong_video":
if (this.curQues.itemType == 'sound') {
if (this.curQues.itemType == "sound") {
this.startWaitVideo();
} else {
this.checkNextQues();
......@@ -1233,7 +1207,6 @@ showStartLight() {
this.checkNextQues();
break;
}
},
showMask(cb) {
......@@ -1241,23 +1214,17 @@ showStartLight() {
mask.opacity = 0;
cc.tween(mask)
.to(0.2, {opacity: 255}, {easing: "sineIn"})
.to(0.2, { opacity: 255 }, { easing: "sineIn" })
.call(() => {
cb && cb();
})
.start();
},
showRestart() {
// this.setCurTipAudioUrl(this.data.finish_audio_url);
const circle = getSprNode('bg_circle');
const circle = getSprNode("bg_circle");
// circle.x = this.canvas.width / 4;
this.canvas.addChild(circle, 5);
......@@ -1268,197 +1235,227 @@ showStartLight() {
.repeatForever()
.start();
const btn = getSprNode('btn_restart');
const btn = getSprNode("btn_restart");
this.canvas.addChild(btn, 6);
btn.x = circle.x;
circle.on('touchstart', () => {
circle.on("touchstart", () => {
this.replay();
})
});
},
replay() {
const middleLayer = cc.find('middleLayer');
const middleLayer = cc.find("middleLayer");
if (middleLayer) {
middleLayer.getComponent('middleLayer').reloadBundle();
middleLayer.getComponent("middleLayer").reloadBundle();
}
},
refreshVideoTimeLabel() {
const currentTime = this.muteVideoPlayer.currentTime
this.curTimeLabel.string = formatTime('mm:ss', new Date(currentTime * 1000));
const currentTime = this.muteVideoPlayer.currentTime;
this.curTimeLabel.string = formatTime(
"mm:ss",
new Date(currentTime * 1000)
);
},
refreshItemTimeLabel(item) {
const currentTime = this.videoPlayer.currentTime
this.curTimeLabel.string = formatTime('mm:ss', new Date(currentTime * 1000));
const currentTime = this.videoPlayer.currentTime;
this.curTimeLabel.string = formatTime(
"mm:ss",
new Date(currentTime * 1000)
);
},
updateCheckStop() {
// console.log("检查停止时间", this.curEndTime);
if (!this.video || this.curEndTime == -1) {
return;
}
if (this.video.currentTime >= this.curEndTime) {
this.video.pause();
this.videoControlBar.emit("update_video_status", 0);
this.video.currentTime = this.curEndTime;
this.curEndTime = -1;
this.curVideoPlayEnd();
// this.videoControlBar.active = false;
}
},
update() {
if (this.isDestroy) {
return;
}
this.updateCheckStop();
// 更新当前进度条
if(this.videoDuration== null) {
this.videoControlBar.emit("update_video_progress", 0)
} else {
this.videoControlBar.emit("update_video_progress", this.video.currentTime / this.videoDuration)
}
// 如果没有正在拖动中 检查是否为题目停止
if(!this.isDragProgressBar) {
this.updateCheckStop();
}
},
// 重置题目相关数据 - 在用户拖动进度条完成以后
restQuesData(curretnTime) {
let userDragTime = curretnTime;
this.resetQuesIndex(userDragTime);
this.initCurQues();
if(this.quesIndex >= 0) {
this.curEndTime = Number(this.curQues.ques_end);
} else {
// 如果没有找到题目索引 则把当前截止时间设置为无穷大
this.curEndTime = -1;
}
this.video.currentTime = userDragTime;
},
// 是否正在拖动进度条
isDragProgressBar: false,
initListener() {
const canvas = cc.find('Canvas');
const canvas = cc.find("Canvas");
let downFlag = false;
const touchStart = (e) => {
this.canvasTouchStart(e);
console.log('touch start');
// console.log("touch start");
if (canvas.hasEventListener(cc.Node.EventType.MOUSE_DOWN)) {
canvas.off(cc.Node.EventType.MOUSE_DOWN, mouseDown)
}
canvas.off(cc.Node.EventType.MOUSE_DOWN, mouseDown);
}
};
const mouseDown = (e) => {
if (!downFlag) {
return;
}
this.canvasTouchStart(e);
console.log('mouse down');
console.log("mouse down");
if (canvas.hasEventListener(cc.Node.EventType.TOUCH_MOVE)) {
canvas.off(cc.Node.EventType.TOUCH_MOVE, touchMove)
this.removeHtmlCanvasListener('touchmove');
canvas.off(cc.Node.EventType.TOUCH_MOVE, touchMove);
this.removeHtmlCanvasListener("touchmove");
}
}
};
const touchMove = (e) => {
this.canvasTouchMove(e);
// console.log('touch move');
if (canvas.hasEventListener(cc.Node.EventType.MOUSE_MOVE)) {
canvas.off(cc.Node.EventType.MOUSE_MOVE, mouseMove)
}
canvas.off(cc.Node.EventType.MOUSE_MOVE, mouseMove);
}
};
const mouseMove = (e) => {
if (!downFlag) {
return;
}
this.canvasTouchMove(e);
console.log('mouse move');
console.log("mouse move");
if (canvas.hasEventListener(cc.Node.EventType.TOUCH_MOVE)) {
canvas.off(cc.Node.EventType.TOUCH_MOVE, touchMove)
this.removeHtmlCanvasListener('touchmove');
}
canvas.off(cc.Node.EventType.TOUCH_MOVE, touchMove);
this.removeHtmlCanvasListener("touchmove");
}
};
const touchEnd = (e) => {
downFlag = false;
this.canvasTouchEnd(e);
if (canvas.hasEventListener(cc.Node.EventType.MOUSE_UP)) {
canvas.off(cc.Node.EventType.MOUSE_UP, mouseUp)
canvas.off(cc.Node.EventType.MOUSE_UP, mouseUp);
}
if (canvas.hasEventListener(cc.Node.EventType.MOUSE_LEAVE)) {
canvas.off(cc.Node.EventType.MOUSE_LEAVE, mouseUp)
canvas.off(cc.Node.EventType.MOUSE_LEAVE, mouseUp);
}
this.removeHtmlTouchEnd();
}
};
const mouseUp = (e) => {
downFlag = false;
this.canvasTouchEnd(e);
if (canvas.hasEventListener(cc.Node.EventType.TOUCH_END)) {
canvas.off(cc.Node.EventType.TOUCH_END, touchEnd)
canvas.off(cc.Node.EventType.TOUCH_END, touchEnd);
}
if (canvas.hasEventListener(cc.Node.EventType.TOUCH_CANCEL)) {
canvas.off(cc.Node.EventType.TOUCH_CANCEL, touchEnd)
}
canvas.off(cc.Node.EventType.TOUCH_CANCEL, touchEnd);
}
};
canvas.on(cc.Node.EventType.TOUCH_START, touchStart);
canvas.on(cc.Node.EventType.MOUSE_DOWN, mouseDown);
canvas.on(cc.Node.EventType.TOUCH_MOVE, touchMove);
canvas.on(cc.Node.EventType.MOUSE_MOVE, mouseMove);
canvas.on(cc.Node.EventType.TOUCH_START, touchStart)
canvas.on(cc.Node.EventType.MOUSE_DOWN, mouseDown)
canvas.on(cc.Node.EventType.TOUCH_END, touchEnd);
canvas.on(cc.Node.EventType.TOUCH_CANCEL, touchEnd);
canvas.on(cc.Node.EventType.MOUSE_UP, mouseUp);
canvas.on(cc.Node.EventType.TOUCH_MOVE, touchMove)
canvas.on(cc.Node.EventType.MOUSE_MOVE, mouseMove)
// 监听组件发来的拖动开始和结束消息
this.videoControlBar.on("on_drag_button", (isDragStart)=>{
if(isDragStart) {
this.hideWaitingVideo();
this.isDragProgressBar = true;
this.video.pause();
this.videoControlBar.emit("update_video_status", 0);
} else {
this.restQuesData(this.video.currentTime);
this.isDragProgressBar = false;
this.video.play();
this.videoControlBar.emit("update_video_status", 1);
}
})
canvas.on(cc.Node.EventType.TOUCH_END, touchEnd)
canvas.on(cc.Node.EventType.TOUCH_CANCEL, touchEnd)
canvas.on(cc.Node.EventType.MOUSE_UP, mouseUp)
// 监听组件发来的拖动百分比
this.videoControlBar.on("on_drag_percent", (percent)=>{
this.video.currentTime = percent * this.videoDuration;
})
// 监听组件发来视频播放、暂停事件
this.videoControlBar.on("video_btn_click", (isPlay)=>{
if(isPlay) {
if(this.isWaitingUserAction) {
this.hideWaitingVideo();
this.restQuesData(this.video.currentTime);
}
this.video.play();
} else {
this.video.pause();
}
})
},
canvasTouchStart(e) {
const pos = e.getLocation();
// this.knife.x = pos.x - e.currentTarget.width / 2;
// this.knife.y = pos.y - e.currentTarget.height / 2;
},
canvasTouchMove(e) {
if (!this._curShowItem) {
return;
}
const pos = e.getLocation();
this._curShowItem.x = (pos.x - e.currentTarget.width / 2) / this._curShowItem.parent.scale;
this._curShowItem.y = (pos.y - e.currentTarget.height / 2) / this._curShowItem.parent.scale;;
this._curShowItem.x =
(pos.x - e.currentTarget.width / 2) / this._curShowItem.parent.scale;
this._curShowItem.y =
(pos.y - e.currentTarget.height / 2) / this._curShowItem.parent.scale;
// console.log('pos: ', pos.x);
},
canvasTouchEnd(e) {
if (!this._curShowItem) {
return;
}
......@@ -1467,37 +1464,36 @@ showStartLight() {
},
checkOnDragEndRect() {
console.log('emptyGroupArr: ', this.emptyGroupArr);
console.log("emptyGroupArr: ", this.emptyGroupArr);
for (let i = 0; i < this.dragEndRectArr.length; i++) {
const rect = this.dragEndRectArr[i];
const worldPos = this._curShowItem.parent.convertToWorldSpaceAR(cc.v2(this._curShowItem.x, this._curShowItem.y));
const worldPos = this._curShowItem.parent.convertToWorldSpaceAR(
cc.v2(this._curShowItem.x, this._curShowItem.y)
);
const worldRect = rect.getBoundingBoxToWorld();
if (worldRect.contains(worldPos)) {
console.log('rect in ')
console.log("rect in ");
this._curShowItem.selectRect = rect;
// this.checkIsDragEndSuccess(rect);
return;
}
}
this.itemBack();
},
checkIsDragEndSuccess(dragItem) {
const rect = dragItem.selectRect;
const worldPos = dragItem.parent.convertToWorldSpaceAR(cc.v2(dragItem.targetPx, dragItem.targetPy));
const worldPos = dragItem.parent.convertToWorldSpaceAR(
cc.v2(dragItem.targetPx, dragItem.targetPy)
);
const worldRect = rect.getBoundingBoxToWorld();
console.log(' worldPos: ', worldPos);
console.log(' worldRect: ', worldRect);
console.log(" worldPos: ", worldPos);
console.log(" worldRect: ", worldRect);
if (worldRect.contains(worldPos)) {
dragItem.x = dragItem.targetPx;
......@@ -1507,63 +1503,46 @@ showStartLight() {
// cc.audioEngine.playEffect(this.rightClip, false, 0.8);
return true;
} else {
return false;
// this.itemBack();
}
},
itemBack() {
cc.audioEngine.playEffect(this.wrongClip, false, 0.8);
cc.tween(this._curShowItem)
.to(0.5, {x: this._curShowItem.baseX, y: this._curShowItem.baseY}, {easing: "elasticOut"})
.to(
0.5,
{ x: this._curShowItem.baseX, y: this._curShowItem.baseY },
{ easing: "elasticOut" }
)
.start();
},
removeHtmlCanvasListener(type) {
// const canvasHtml = document.querySelector('canvas');
// canvasHtml.addEventListener(type, (e) => {})
},
removeHtmlTouchEnd() {
// const canvasHtml = document.querySelector('canvas');
// canvasHtml.removeEventListener('touchend', this.htmlCanvasTouchendFunc, this);
},
initHotZone() {
this.initHotZoneBg();
},
hotZoneBg: null,
initHotZoneBg() {
for (let i = 0; i < this.data.quesArr.length; i++) {
const data = this.data.quesArr[i];
const hotZoneBg = new cc.Node();
hotZoneBg.name = 'hotZoneBg';
hotZoneBg.parent = cc.find('Canvas');
hotZoneBg.name = "hotZoneBg";
hotZoneBg.parent = cc.find("Canvas");
hotZoneBg.data = data;
data.hotZoneBg = hotZoneBg;
......@@ -1574,39 +1553,32 @@ showStartLight() {
}
cc.loader.load({ url: data.bgItem.url }, (err, img) => {
hotZoneBg.width = img.width;
hotZoneBg.height = img.height;
const sprNode = new cc.Node();
sprNode.name = 'bgItemSpr'
sprNode.name = "bgItemSpr";
var sf = new cc.SpriteFrame(img);
// const spr = hotZoneBg.addComponent(cc.Sprite);
const spr = sprNode.addComponent(cc.Sprite);
spr.spriteFrame = sf
spr.spriteFrame = sf;
sprNode.width = hotZoneBg.width;
sprNode.height = hotZoneBg.height;
sprNode.parent = hotZoneBg;
sprNode.opacity = 0;
// const sx = this.canvas.width / hotZoneBg.width;
const sy = this.canvas.height / hotZoneBg.height;
// const s = Math.min(sx, sy);
hotZoneBg.scale = sy;
if (data.itemType != 'sound') {
if (data.itemType != "sound") {
this.initHotZoneItem(hotZoneBg);
}
});
}
// this.hotZoneBg = new cc.Node();
// this.hotZoneBg.name = 'hotZoneBg';
// this.hotZoneBg.parent = cc.find('Canvas');
......@@ -1625,8 +1597,6 @@ showStartLight() {
// this.hotZoneBg.width = img.width;
// this.hotZoneBg.height = img.height;
// const sprNode = new cc.Node();
// sprNode.name = 'bgItemSpr'
// var sf = new cc.SpriteFrame(img);
......@@ -1638,7 +1608,6 @@ showStartLight() {
// sprNode.parent = this.hotZoneBg;
// window['bg'] = sprNode
// const sx = this.canvas.width / this.hotZoneBg.width;
// const sy = (this.canvas.height - titleH) / this.hotZoneBg.height;
// const s = Math.min(sx, sy);
......@@ -1648,16 +1617,10 @@ showStartLight() {
// this.hotZoneBg.y = 0 - titleH / 2;
// // console.log('this.hotZoneBg.y', this.hotZoneBg.y);
// // this.data.bgItem.isShowDebugLine = true;
// this.initHotZoneItem();
// });
},
initHotZoneItem(bg) {
......@@ -1669,7 +1632,7 @@ showStartLight() {
this.setOneHand(item, bg);
break;
case "1" :
case "1":
this.setOneAnimaSmall(item, bg);
break;
......@@ -1680,25 +1643,19 @@ showStartLight() {
default:
break;
}
});
},
setOneDragEndRect(data, bg) {
console.log(" in setOneDragEndRect");
const quesData = bg.data;
const rate = (bg.scale * bg.width) / quesData.bgItem.rect.width;
const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index;
rectNode.name = "rect" + data.index;
bg.addChild(rectNode);
const ctx = rectNode.addComponent(cc.Graphics);
// 红色矩形
ctx.lineWidth = 4;
......@@ -1709,7 +1666,6 @@ showStartLight() {
// console.log('scale: ', scale);
// console.log('scale2: ', scale / data.mapScale);
rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale;
rectNode.x = -bg.width / 2 + data.rect.x * scale;
......@@ -1718,7 +1674,6 @@ showStartLight() {
rectNode.anchorX = rectNode.anchorY = 0;
if (quesData.bgItem.isShowDebugLine) {
ctx.rect(0, 0, rectNode.width, rectNode.height);
}
......@@ -1734,71 +1689,64 @@ showStartLight() {
rectNode.audioClip = audioClip;
});
}
},
setOneDragPic(data, bg) {
const quesData = bg.data;
const rate = (bg.scale * bg.width) / quesData.bgItem.rect.width;
const picNode = new cc.Node();
picNode.name= 'pic' + data.index;
picNode.name = "pic" + data.index;
picNode.data = data;
bg.addChild(picNode);
cc.loader.load({url: data.pic_url}, (err, img) => {
cc.loader.load({ url: data.pic_url }, (err, img) => {
const spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img)
spr.spriteFrame = new cc.SpriteFrame(img);
const scale = rate / bg.scaleY;
console.log('picNode.width: ', picNode.width);
console.log('data.rect.width: ', data.rect.width);
console.log('scale: ', scale);
console.log("picNode.width: ", picNode.width);
console.log("data.rect.width: ", data.rect.width);
console.log("scale: ", scale);
// picNode.width = data.rect.width * scale;
// picNode.height = data.rect.height * scale;
const picScale = data.rect.width * scale / picNode.width;
const picScale = (data.rect.width * scale) / picNode.width;
picNode.scale = picScale;
picNode.x = -bg.width / 2 + data.rect.x * scale;
picNode.y = bg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.y =
bg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.x += picNode.width / 2 * picNode.scaleX;
picNode.y += picNode.height / 2 * picNode.scaleX;
picNode.x += (picNode.width / 2) * picNode.scaleX;
picNode.y += (picNode.height / 2) * picNode.scaleX;
// picNode.anchorX = picNode.anchorY = 0;
// if (data.audio_url) {
// this.addPicAudio(picNode);
// }
this.addDragPoint(picNode, data, bg)
this.addDragPoint(picNode, data, bg);
if (!quesData.dragPicArr) {
quesData.dragPicArr = [];
}
quesData.dragPicArr.push(picNode);
});
},
addDragPoint(picNode, data, bg) {
const quesData = bg.data;
picNode.baseX = picNode.x;
picNode.baseY = picNode.y;
const realRate = bg.width / quesData.bgItem.rect.width;
picNode.targetPx = -bg.width / 2 + ( data.dragDot.x - quesData.bgItem.rect.x ) * realRate;
picNode.targetPy = bg.height / 2 - (data.dragDot.y - quesData.bgItem.rect.y) * realRate;
picNode.targetPx =
-bg.width / 2 + (data.dragDot.x - quesData.bgItem.rect.x) * realRate;
picNode.targetPy =
bg.height / 2 - (data.dragDot.y - quesData.bgItem.rect.y) * realRate;
// if (data.audio_url) {
// cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
......@@ -1806,7 +1754,6 @@ showStartLight() {
// });
// }
picNode.on(cc.Node.EventType.TOUCH_START, () => {
// if (picNode.isDragEnd) {
// if (picNode.audioClip) {
......@@ -1816,20 +1763,15 @@ showStartLight() {
// return;
// }
this._curShowItem = picNode;
})
});
},
setOneAction(data) {
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const rate =
(this.hotZoneBg.scale * this.hotZoneBg.width) /
this.data.bgItem.rect.width;
const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index;
rectNode.name = "rect" + data.index;
this.hotZoneBg.addChild(rectNode);
const ctx = rectNode.addComponent(cc.Graphics);
......@@ -1843,7 +1785,10 @@ showStartLight() {
rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale;
rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
rectNode.y =
this.hotZoneBg.height / 2 -
data.rect.height * scale -
data.rect.y * scale;
const { x, y, width, height } = rectNode;
rectNode.anchorX = rectNode.anchorY = 0;
......@@ -1853,42 +1798,33 @@ showStartLight() {
ctx.stroke();
ctx.fill();
console.log('setOneAction ~~ data: ', data)
const actionData = data['actionData_' + data.gIdx];
console.log("setOneAction ~~ data: ", data);
const actionData = data["actionData_" + data.gIdx];
if (!actionData) {
return;
}
if (actionData.type == 'text') {
if (actionData.type == "text") {
const label = this.setOneActionText(rectNode, actionData);
label.node.scale = scale * data.fontScale;
// label.overflow = cc.Label.Overflow.NONE;
// label.node.setContentSize(new cc.Size(0, lineHeight));
label["_forceUpdateRenderData"](true);
} else if (actionData.type == 'pic') {
} else if (actionData.type == "pic") {
const pic = this.setOneActionPic(rectNode, actionData);
} else if (actionData.type == 'anima') {
} else if (actionData.type == "anima") {
const anima = this.setOneActionAnima(rectNode, actionData);
}
},
setOneActionText(rectNode, actionData) {
// const labelNode = new cc.Node();
// labelNode.parent = rectNode;
const label = this.getLabel(); // labelNode.addComponent(cc.Label);
const labelNode = label.node;
labelNode.parent = rectNode;
label.font = cc.find('Canvas/res/font/aharoni').getComponent(cc.Label).font;
label.font = cc.find("Canvas/res/font/aharoni").getComponent(cc.Label).font;
label.string = actionData.text;
// label.string = `<size=${size}><color=#751e00>${this.curGroup.title }</color></size>`
// label.lineHeight = size;
......@@ -1897,52 +1833,50 @@ showStartLight() {
// labelNode.anchorY = 1
labelNode.color = cc.Color.BLACK;
const opArr = actionData.changeOption
const opArr = actionData.changeOption;
// console.log('opArr', opArr);
const tweenArr = [];
for (let i = 0; i < opArr.length; i++) {
const opData = opArr[i];
console.log('opArr[0]', opArr[i])
if (opData[0] == 'fontColor') {
console.log("opArr[0]", opArr[i]);
if (opData[0] == "fontColor") {
const color = new cc.Color();
cc.Color.fromHEX(color, opData[1]);
labelNode.color = color;
} else if (opData[0] == 'opacity') {
} else if (opData[0] == "opacity") {
// console.log('opData: ', opData)
labelNode.opacity = Number(opData[1] / 100 * 255) + 0.1;
labelNode.opacity = Number((opData[1] / 100) * 255) + 0.1;
// console.log(labelNode.opacity);
tweenArr.push({ item: labelNode, option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[0] },)
tweenArr.push({
item: labelNode,
option: `{"${opData[0]}" : ${(opData[2] / 100) * 255}}`,
optionName: opData[0],
});
} else {
label[opData[0]] = opData[1];
tweenArr.push({ item: label, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[0] })
tweenArr.push({
item: label,
option: `{"${opData[0]}" : ${opData[2]}}`,
optionName: opData[0],
});
}
}
if (actionData.audio_url) {
cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => {
labelNode.audioClip = audioClip;
});
}
label.lineHeight = label.fontSize;
labelNode.y += rectNode.height / 2;
labelNode.x += rectNode.width / 2;
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
if (labelNode.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(labelNode.audioClip, false, 0.8);
......@@ -1963,22 +1897,19 @@ showStartLight() {
// console.log( JSON.parse(tweenData.option) );
if (tweenData.optionName == 'opacity') {
console.log('~~~ ', tweenData.item[tweenData.optionName]);
if (tweenData.optionName == "opacity") {
console.log("~~~ ", tweenData.item[tweenData.optionName]);
// tweenData.item[tweenData.optionName] = tweenData.item[tweenData.optionName] + 1
cc.tween(tweenData.item)
.to(actionData.changeTime, JSON.parse(tweenData.option))
.start();
}
}
// cc.tween({})
// .to(5, { scale: (Math.random() - 0.5) + 1})
// .start();
});
// labelNode.opacity = 255;
......@@ -1987,15 +1918,13 @@ showStartLight() {
},
setOneActionPic(rectNode, actionData) {
console.log('setOneActionPic actionData: ', actionData)
console.log("setOneActionPic actionData: ", actionData);
const picNode = new cc.Node();
rectNode.addChild(picNode);
cc.loader.load({ url: actionData.pic_url }, (err, img) => {
const spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img)
spr.spriteFrame = new cc.SpriteFrame(img);
picNode.y += rectNode.height / 2;
picNode.x += rectNode.width / 2;
......@@ -2003,35 +1932,34 @@ showStartLight() {
picNode.scaleX = rectNode.width / picNode.width;
picNode.scaleY = rectNode.height / picNode.height;
const opArr = actionData.changeOption
const opArr = actionData.changeOption;
const tweenArr = [];
for (let i = 0; i < opArr.length; i++) {
const opData = opArr[i];
console.log('opData: ~~~ ', opData);
console.log("opData: ~~~ ", opData);
if (opData[0] == 'opacity') {
picNode.opacity = Number(opData[1] / 100 * 255) + 0.1;
if (opData[0] == "opacity") {
picNode.opacity = Number((opData[1] / 100) * 255) + 0.1;
console.log(picNode.opacity);
tweenArr.push({ item: picNode, option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[0] },)
tweenArr.push({
item: picNode,
option: `{"${opData[0]}" : ${(opData[2] / 100) * 255}}`,
optionName: opData[0],
});
} else {
// picNode[opData[0]] = Number(opData[1]);
// tweenArr.push({item: picNode, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[0]})
}
if (actionData.audio_url) {
cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => {
rectNode.audioClip = audioClip;
});
}
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
if (rectNode.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8);
......@@ -2045,22 +1973,18 @@ showStartLight() {
for (let i = 0; i < tweenArr.length; i++) {
const tweenData = tweenArr[i];
if (tweenData.optionName == 'opacity') {
if (tweenData.optionName == "opacity") {
cc.tween(tweenData.item)
.to(actionData.changeTime, JSON.parse(tweenData.option))
.start();
}
}
});
}
});
},
setOneActionAnima(rectNode, actionData) {
const animaNode = new cc.Node();
rectNode.addChild(animaNode);
......@@ -2074,20 +1998,15 @@ showStartLight() {
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
if (!data.texPngData) {
return
return;
}
const image = data.texPngData.url//"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url//"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
const image = data.texPngData.url; //"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url; //"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url; //"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, (error, texture) => {
cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
cc.loader.load({ url: atlas, type: "txt" }, (error, atlasJson) => {
cc.loader.load({ url: ske, type: "txt" }, (error, dragonBonesJson) => {
const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = texture;
......@@ -2098,7 +2017,6 @@ showStartLight() {
dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;
let json = JSON.parse(asset.dragonBonesJson);
let armatures = json["armature"];
let armatureNames = [];
......@@ -2139,7 +2057,6 @@ showStartLight() {
// });
}
// animaNode.x = rectNode.x + rectNode.width / 2;
// animaNode.y = rectNode.y + rectNode.height / 2;
......@@ -2148,46 +2065,43 @@ showStartLight() {
// const scale = Math.min(sx, sy);
// animaNode.scale = scale;
animaNode.y += rectNode.height / 2;
animaNode.x += rectNode.width / 2;
animaNode.scaleX = rectNode.width / animaNode.width;
animaNode.scaleY = rectNode.height / animaNode.height;
const opArr = actionData.changeOption
const opArr = actionData.changeOption;
const tweenArr = [];
for (let i = 0; i < opArr.length; i++) {
const opData = opArr[i];
console.log('opData: ~~~ ', opData);
console.log("opData: ~~~ ", opData);
if (opData[0] == 'opacity') {
animaNode.opacity = Number(opData[1] / 100 * 255) + 0.1;
if (opData[0] == "opacity") {
animaNode.opacity = Number((opData[1] / 100) * 255) + 0.1;
console.log(animaNode.opacity);
tweenArr.push({ item: animaNode, option: `{"${opData[0]}" : ${opData[2] / 100 * 255}}`, optionName: opData[2] == null ? '' : opData[0] },)
tweenArr.push({
item: animaNode,
option: `{"${opData[0]}" : ${(opData[2] / 100) * 255}}`,
optionName: opData[2] == null ? "" : opData[0],
});
} else {
// animaNode[opData[0]] = Number(opData[1]);
// tweenArr.push({item: animaNode, option: `{"${opData[0]}" : ${opData[2]}}`, optionName: opData[2] == null ? '' : opData[0]})
}
if (actionData.audio_url) {
cc.assetManager.loadRemote(actionData.audio_url, (err, audioClip) => {
cc.assetManager.loadRemote(
actionData.audio_url,
(err, audioClip) => {
rectNode.audioClip = audioClip;
});
}
);
}
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
if (rectNode.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8);
......@@ -2201,45 +2115,34 @@ showStartLight() {
for (let j = 0; j < tweenArr.length; j++) {
const tweenData = tweenArr[j];
console.log('tweenData: ', tweenData);
console.log("tweenData: ", tweenData);
if (tweenData.optionName) {
cc.tween(tweenData.item)
.to(actionData.changeTime, JSON.parse(tweenData.option))
.start();
}
}
if (animationNames.length > 0) {
dragonDisplay.playAnimation(animationNames[0], 1);
}
});
}
});
});
});
},
setOneAnimaSmall(data) {
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const rate =
(this.hotZoneBg.scale * this.hotZoneBg.width) /
this.data.bgItem.rect.width;
const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index;
rectNode.name = "rect" + data.index;
this.hotZoneBg.addChild(rectNode);
const ctx = rectNode.addComponent(cc.Graphics);
// 红色矩形
ctx.lineWidth = 4;
......@@ -2251,47 +2154,40 @@ showStartLight() {
rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale;
rectNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
rectNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
rectNode.y =
this.hotZoneBg.height / 2 -
data.rect.height * scale -
data.rect.y * scale;
rectNode.anchorX = rectNode.anchorY = 0;
if (this.data.bgItem.isShowDebugLine) {
ctx.rect(0, 0, rectNode.width, rectNode.height);
}
ctx.stroke();
ctx.fill();
const animaNode = new cc.Node();
animaNode.name = 'anima_' + data.index;
animaNode.name = "anima_" + data.index;
this.hotZoneBg.addChild(animaNode);
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
animaNode.audioClip = audioClip;
});
}
const dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
if (!data.texPngData) {
return
return;
}
const image = data.texPngData.url//"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url//"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url//"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
const image = data.texPngData.url; //"http://staging-teach.cdn.ireadabc.com/5a0c5af3e952acd0ac83a6e5c6f03ff1.png";
const ske = data.skeJsonData.url; //"http://staging-teach.cdn.ireadabc.com/bd825dcceea298d1146be8067ae3d17f.json";
const atlas = data.texJsonData.url; //"http://staging-teach.cdn.ireadabc.com/246f8991b729fa3e5a7f4802de828efa.json";
cc.loader.load(image, (error, texture) => {
cc.loader.load({ url: atlas, type: 'txt' }, (error, atlasJson) => {
cc.loader.load({ url: ske, type: 'txt' }, (error, dragonBonesJson) => {
cc.loader.load({ url: atlas, type: "txt" }, (error, atlasJson) => {
cc.loader.load({ url: ske, type: "txt" }, (error, dragonBonesJson) => {
const atlas = new dragonBones.DragonBonesAtlasAsset();
atlas.atlasJson = atlasJson;
atlas.texture = texture;
......@@ -2302,8 +2198,6 @@ showStartLight() {
dragonDisplay.dragonAtlasAsset = atlas;
dragonDisplay.dragonAsset = asset;
let json = JSON.parse(asset.dragonBonesJson);
let armatures = json["armature"];
// console.log('armatures: ', armatures);
......@@ -2324,16 +2218,16 @@ showStartLight() {
}
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
if (rectNode.isClicked) {
// return;
}
rectNode.isClicked = true;
console.log('clicked');
console.log("clicked");
if (animaNode.audioClip) {
cc.audioEngine.stopAllEffects();
cc.director.emit('STOP_ALL_AUDIO')
cc.director.emit("STOP_ALL_AUDIO");
cc.audioEngine.playEffect(animaNode.audioClip, false, 0.8);
}
......@@ -2343,7 +2237,6 @@ showStartLight() {
});
}
animaNode.x = rectNode.x + rectNode.width / 2;
animaNode.y = rectNode.y + rectNode.height / 2;
......@@ -2351,11 +2244,9 @@ showStartLight() {
const sy = rectNode.height / animaNode.height;
const scale = Math.min(sx, sy);
animaNode.scale = scale;
});
});
});
},
setSubmitRect(data, bg) {
......@@ -2363,10 +2254,9 @@ showStartLight() {
const rate = (bg.scale * bg.width) / quesData.bgItem.rect.width;
const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index;
rectNode.name = "rect" + data.index;
bg.addChild(rectNode);
const ctx = rectNode.addComponent(cc.Graphics);
// 红色矩形
ctx.lineWidth = 4;
......@@ -2375,8 +2265,6 @@ showStartLight() {
const scale = rate / bg.scaleY;
rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale;
rectNode.x = -bg.width / 2 + data.rect.x * scale;
......@@ -2385,14 +2273,13 @@ showStartLight() {
rectNode.anchorX = rectNode.anchorY = 0;
if (quesData.bgItem.isShowDebugLine) {
ctx.rect(0, 0, rectNode.width, rectNode.height);
}
ctx.stroke();
ctx.fill();
console.log('```data: ', data)
console.log("```data: ", data);
// if (data.audio_url) {
// cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
......@@ -2401,14 +2288,14 @@ showStartLight() {
// }
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
if (rectNode.isClicked) {
// return;
}
rectNode.isClicked = true;
if (this.curQues.itemType == "submit") {
this.checkSubmitSelectQues();
} else if (this.curQues.itemType == "drag"){
} else if (this.curQues.itemType == "drag") {
this.checkSubmitDragQues();
}
// console.log('clicked');
......@@ -2427,15 +2314,13 @@ showStartLight() {
});
},
setOptPic(data, bg) {
const quesData = bg.data;
const rate = (bg.scale * bg.width) / quesData.bgItem.rect.width;
const picNode = new cc.Node();
picNode.name = 'pic' + data.index;
picNode.name = "pic" + data.index;
picNode.data = data;
bg.addChild(picNode);
picNode.data = data;
......@@ -2445,7 +2330,6 @@ showStartLight() {
}
quesData.optPicArr.push(picNode);
const scale = rate / bg.scaleY;
picNode.width = data.rect.width * scale;
picNode.height = data.rect.height * scale;
......@@ -2454,9 +2338,7 @@ showStartLight() {
picNode.anchorX = picNode.anchorY = 0;
getSprNodeByUrl(data.pic_url, (spr) => {
const sprNode = spr.node;
sprNode.scaleX = picNode.width / sprNode.width;
......@@ -2465,10 +2347,9 @@ showStartLight() {
sprNode.parent = picNode;
picNode.spr1 = sprNode;
})
});
getSprNodeByUrl(data.pic2_url, (spr) => {
const sprNode = spr.node;
sprNode.scaleX = picNode.width / sprNode.width;
......@@ -2478,12 +2359,10 @@ showStartLight() {
sprNode.opacity = 0;
picNode.spr2 = sprNode;
})
});
picNode.isSelect = false;
picNode.on("touchstart", () => {
this.hideAllOptSelect();
picNode.isSelect = true;
......@@ -2495,14 +2374,12 @@ showStartLight() {
picNode.spr1.opacity = 255;
picNode.spr2.opacity = 0;
}
})
});
if (data.audio_url) {
this.addPicAudio(picNode);
}
// cc.loader.load({ url: data.pic_url }, (err, img) => {
// const spr = picNode.addComponent(cc.Sprite);
......@@ -2522,46 +2399,47 @@ showStartLight() {
// // }
// });
},
hideAllOptSelect() {
const optPicArr = this.curQues.optPicArr;
optPicArr.forEach(it => {
optPicArr.forEach((it) => {
it.isSelect = false;
it.spr1.opacity = 255;
it.spr2.opacity = 0;
})
});
},
setOnePic(data) {
const rate = (this.hotZoneBg.scale * this.hotZoneBg.width) / this.data.bgItem.rect.width;
const rate =
(this.hotZoneBg.scale * this.hotZoneBg.width) /
this.data.bgItem.rect.width;
const picNode = new cc.Node();
picNode.name = 'pic' + data.index;
picNode.name = "pic" + data.index;
picNode.data = data;
this.hotZoneBg.addChild(picNode);
cc.loader.load({ url: data.pic_url }, (err, img) => {
const spr = picNode.addComponent(cc.Sprite);
spr.spriteFrame = new cc.SpriteFrame(img)
spr.spriteFrame = new cc.SpriteFrame(img);
const scale = rate / this.hotZoneBg.scaleY;
picNode.width = data.rect.width * scale;
picNode.height = data.rect.height * scale;
picNode.x = -this.hotZoneBg.width / 2 + data.rect.x * scale;
picNode.y = this.hotZoneBg.height / 2 - data.rect.height * scale - data.rect.y * scale;
picNode.y =
this.hotZoneBg.height / 2 -
data.rect.height * scale -
data.rect.y * scale;
picNode.anchorX = picNode.anchorY = 0;
if (data.audio_url) {
this.addPicAudio(picNode);
}
});
},
setOneAudioRect(data, bg) {
......@@ -2569,10 +2447,9 @@ showStartLight() {
const rate = (bg.scale * bg.width) / quesData.bgItem.rect.width;
const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index;
rectNode.name = "rect" + data.index;
bg.addChild(rectNode);
const ctx = rectNode.addComponent(cc.Graphics);
// 红色矩形
ctx.lineWidth = 4;
......@@ -2589,14 +2466,13 @@ showStartLight() {
rectNode.anchorX = rectNode.anchorY = 0;
if (quesData.bgItem.isShowDebugLine) {
ctx.rect(0, 0, rectNode.width, rectNode.height);
}
ctx.stroke();
ctx.fill();
console.log('```data: ', data)
console.log("```data: ", data);
if (data.audio_url) {
cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
......@@ -2605,12 +2481,12 @@ showStartLight() {
}
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
if (rectNode.isClicked) {
// return;
}
rectNode.isClicked = true;
console.log('clicked');
console.log("clicked");
if (rectNode.audioClip) {
// cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(rectNode.audioClip, false, 0.8);
......@@ -2619,11 +2495,11 @@ showStartLight() {
},
setOneHand(data, bg) {
const rectNode = this.setOneRect(data, bg);
const worldPos = rectNode.parent.convertToWorldSpaceAR(cc.v2(rectNode.x + rectNode.width / 2, rectNode.y + rectNode.height / 2))
const worldPos = rectNode.parent.convertToWorldSpaceAR(
cc.v2(rectNode.x + rectNode.width / 2, rectNode.y + rectNode.height / 2)
);
const pos = this.hand.parent.convertToNodeSpaceAR(worldPos);
bg.handX = pos.x;
......@@ -2635,10 +2511,9 @@ showStartLight() {
const rate = (bg.scale * bg.width) / quesData.bgItem.rect.width;
const rectNode = new cc.Node();
rectNode.name = 'rect' + data.index;
rectNode.name = "rect" + data.index;
bg.addChild(rectNode);
const ctx = rectNode.addComponent(cc.Graphics);
// 红色矩形
ctx.lineWidth = 4;
......@@ -2649,7 +2524,6 @@ showStartLight() {
// console.log('scale: ', scale);
// console.log('scale2: ', scale / data.mapScale);
rectNode.width = data.rect.width * scale;
rectNode.height = data.rect.height * scale;
rectNode.x = -bg.width / 2 + data.rect.x * scale;
......@@ -2658,14 +2532,13 @@ showStartLight() {
rectNode.anchorX = rectNode.anchorY = 0;
if (quesData.bgItem.isShowDebugLine || this.data.isDebug) {
ctx.rect(0, 0, rectNode.width, rectNode.height);
}
ctx.stroke();
ctx.fill();
console.log('```data: ', data)
console.log("```data: ", data);
// if (data.audio_url) {
// cc.assetManager.loadRemote(data.audio_url, (err, audioClip) => {
......@@ -2674,7 +2547,7 @@ showStartLight() {
// }
rectNode.addComponent(cc.Button);
rectNode.on('click', () => {
rectNode.on("click", () => {
// if (rectNode.isClicked) {
// return;
// }
......@@ -2682,7 +2555,6 @@ showStartLight() {
// console.log('clicked');
// this.video.pause();
// if (data.selectType == 'right') {
// this.curQues.isRight = true;
// this.startRightVideo();
......@@ -2702,18 +2574,15 @@ showStartLight() {
const id = data.index;
bg.active = false;
this.hand.active = false;
console.log("跳转", data.index)
this.showMask(() => {
if (!this.isLocal) {
callMiddleLayerFunction('PSQS_jump_to_question', {step: id}, null)
callMiddleLayerFunction("PSQS_jump_to_question", { step: id }, null);
}
})
});
});
return rectNode;
},
addPicAudio(picNode) {
......@@ -2724,7 +2593,7 @@ showStartLight() {
});
picNode.addComponent(cc.Button);
picNode.on('click', () => {
picNode.on("click", () => {
if (picNode.audioClip) {
cc.audioEngine.stopAllEffects();
cc.audioEngine.playEffect(picNode.audioClip, false, 0.8);
......@@ -2733,15 +2602,15 @@ showStartLight() {
},
getLabel() {
const resLabel = cc.find("Canvas/res/label")
const labelNode = cc.instantiate(resLabel)
const resLabel = cc.find("Canvas/res/label");
const labelNode = cc.instantiate(resLabel);
const label = labelNode.getComponent(cc.Label);
return label;
},
getRichText() {
const resLabel = cc.find("Canvas/res/label")
const resLabel = cc.find("Canvas/res/label");
const label = resLabel.getComponent(cc.Label);
const fontFamily = label.fontFamily;
......@@ -2749,37 +2618,33 @@ showStartLight() {
const richText = node.addComponent(cc.RichText);
richText.fontFamily = fontFamily;
return richText;
},
getAnim(resName) {
const anim = cc.find("Canvas/res/anim/" + resName);
const newAnim = cc.instantiate(anim)
const newAnim = cc.instantiate(anim);
return newAnim;
},
checkSubmitDragQues() {
console.log('in checkSubmitDragQues');
console.log("in checkSubmitDragQues");
let isRight = true;
const dragPicArr = this.curQues.dragPicArr;
for (let i = 0; i < dragPicArr.length; i++) {
const isDragRight = this.checkIsDragEndSuccess(dragPicArr[i]);
if (!isDragRight) {
console.log("dragItem: ", dragPicArr[i]);
console.log("drag fail ");
isRight = false;
break;
}
}
this.video.pause();
this.videoControlBar.emit("update_video_status", 0);
this.curQues.isRight = isRight;
if (isRight) {
this.startRightVideo();
......@@ -2788,10 +2653,7 @@ showStartLight() {
}
},
checkSubmitSelectQues() {
let isRight = true;
const optPicArr = this.curQues.optPicArr;
for (let i = 0; i < optPicArr.length; i++) {
......@@ -2801,51 +2663,47 @@ showStartLight() {
// console.log('data.selectType: ', data.selectType);
if (optPicArr[i].isSelect) {
if (data.selectType != 'right') {
if (data.selectType != "right") {
isRight = false;
break;
}
} else {
if (data.selectType == 'right') {
if (data.selectType == "right") {
isRight = false;
break;
}
}
}
console.log('clicked');
console.log("clicked");
this.video.pause();
this.videoControlBar.emit("update_video_status", 0);
this.curQues.isRight = isRight;
if (isRight) {
this.startRightVideo();
} else {
this.startWrongVideo();
}
},
httpHeadCall(requsetUrl, callback) {
let xhr = new XMLHttpRequest();
console.log("Status: Send Post Request to " + requsetUrl);
try {
xhr.onreadystatechange = () => {
try {
console.log('xhr.readyState: ', xhr.readyState);
console.log("xhr.readyState: ", xhr.readyState);
if (xhr.readyState == 4) {
if ((xhr.status >= 200 && xhr.status < 400)) {
if (xhr.status >= 200 && xhr.status < 400) {
callback(true);
} else {
callback(false);
}
}
} catch (e) {
console.log(e)
console.log(e);
}
};
......@@ -2856,7 +2714,6 @@ showStartLight() {
// xhr.send(JSON.stringify(requestData));
xhr.send();
xhr.timeout = 15000;
xhr.onerror = (e) => {
console.log("汪汪汪 posterror", e);
......@@ -2867,23 +2724,17 @@ showStartLight() {
console.log("汪汪汪 ontimeout", e);
callback(false);
};
} catch (e) {
console.log("Send Get Request error: ", e)
console.log("Send Get Request error: ", e);
}
},
isDestroy: null,
onDestroy() {
this.isDestroy = true;
cc.Tween.stopAll();
cc.game.canvas.style.backgroundColor = '#000000';
cc.game.canvas.style.backgroundColor = "#000000";
// this.pauseVideo();
}
},
});
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