Commit 5832d468 authored by Tt's avatar Tt

代码调整

parent b31da49b
{"ver":"1.1.2","uuid":"39a67a55-d6ca-4302-bf68-bea091301858","isBundle":false,"bundleName":"","priority":1,"compressionType":{},"optimizeHotUpdate":{},"inlineSpriteFrames":{},"isRemoteBundle":{"ios":false,"android":false},"subMetas":{}}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "39a67a55-d6ca-4302-bf68-bea091301858",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {
"ios": false,
"android": false
},
"subMetas": {}
}
\ No newline at end of file
import { asyncDelay, onHomeworkFinish } from "../script/util_DG16";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent_DG16";
import Boy from "../script/ui/boy_DG16";
import QuestionView from "../script/ui/question_DG16";
import videoCtrl from "../script/ui/videoCtrl_DG16";
import pg from "../../scene/pg_dg29_museum";
import dg29_museum_game from "../../scene/dg29_museum_game";
......@@ -33,7 +31,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
qustionCom: QuestionView = null;
// qustionCom: QuestionView = null;
_totalIndex: any;
_roundIndex: number;
playGuide2: any;
......@@ -106,97 +104,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
initView() {
this.initBg();
// this.btn_next.on("click", () => {
// this.playLocalAudio("btn")
// if (!cc.find('middleLayer')) {
// console.log("==点击了下一页按钮==")
// return;
// }
// const middleLayer = cc.find('middleLayer').getComponent('middleLayer');
// middleLayer.goNextPage(); // 跳转到下一页
// }, this)
this.videoCtrl.active = false;
this.qustionCom = this.qustionLayer.getComponent(QuestionView);
// this._totalIndex = this.data.contentObj.dataArray.length;
this._roundIndex = 0;
this.firstRound = true
this.doWrongTime = 0;
// cc.log(JSON.stringify(this.data, null, 2))
this.WrongList = [];
this.qustionCom.hide();
// this.boyNode.x = cc.winSize.width;
// this.boyNode.getComponent(Boy).playRun(-1);
// cc.tween(this.boyNode).to(3, { x: 0 }).call(() => {
// this.boyNode.getComponent(Boy).playtalk(-1);
// this.playAudioByUrl(this.data.audio_url_guide, () => {
// this.boyNode.scaleX = -0.65;
// this.log("playRun start")
// this.boyNode.getComponent(Boy).playRun(-1);
// cc.tween(this.boyNode).to(1, { x: 500 }).call(() => {
// this.log("playRun end")
// this.boyNode.scaleX = 0.65;
// this.boyNode.getComponent(Boy).playNormal();
// this.qustionCom.show();
// this.doRound()
// }).start();
// })
// }).start()
}
doRound() {
if (this._roundIndex < this._totalIndex) {
let data = this.data.contentObj.dataArray[this._roundIndex];
let index = data.option_1_isRight ? 0 : 1;
this.qustionCom.init(data, index, this._roundIndex + 1, this._totalIndex, async (isRight) => {
if (isRight) {
this.playLocalAudio("right");
this.boyNode.getComponent(Boy).playGood(1);
} else {
this.WrongList.push(data);
this.doWrongTime++;
this.playLocalAudio("wrong")
this.boyNode.getComponent(Boy).playInvite(1);
}
await asyncDelay(1.5)
this.doRound();
})
this._roundIndex++;
} else {
this.qustionCom.hide()
this.boyNode.getComponent(Boy).playRun(-1);
cc.tween(this.boyNode).to(1, { x: 0 }).call(() => {
this.boyNode.getComponent(Boy).playtalk(-1);
let audiourl = this.doWrongTime > 0 ? this.data.audio_url_wrong : this.data.audio_url_right;
this.playAudioByUrl(audiourl, () => {
this.boyNode.scaleX = -0.65;
this.boyNode.getComponent(Boy).playRun(-1);
cc.tween(this.boyNode).to(1, { x: 500 }).call(async () => {
this.boyNode.scaleX = 0.65;
this.boyNode.getComponent(Boy).playNormal();
this.playVideo();
}).start();
})
}).start()
}
}
async playVideo() {
this.videoCtrl.active = true;
this.node.getChildByName("bg").active = false;
......@@ -209,52 +126,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
await asyncDelay(0.1);
this.boyNode.active = false;
}
initWorongLogic() {
this._totalIndex = this.WrongList.length;
this._roundIndex = 0;
this.qustionCom.show();
this.doWrongRound();
}
doWrongRound() {
if (this._roundIndex < this._totalIndex) {
let data = this.WrongList[this._roundIndex];
let index = data.option_1_isRight ? 0 : 1;
this.qustionCom.init(data, index, this._roundIndex + 1, this._totalIndex, async (isRight) => {
if (isRight) {
this.playLocalAudio("right");
this.boyNode.getComponent(Boy).playGood(1);
} else {
this.playLocalAudio("wrong")
this.boyNode.getComponent(Boy).playInvite(1);
}
await asyncDelay(1.5)
this.doWrongRound();
})
this._roundIndex++;
} else {
this.qustionCom.hide();
this.boyNode.getComponent(Boy).playRun(-1);
cc.tween(this.boyNode).to(1, { x: 0 }).call(() => {
this.boyNode.getComponent(Boy).playtalk(-1);
this.playAudioByUrl(this.data.audio_url_end, () => {
this.boyNode.scaleX = -0.65;
this.boyNode.getComponent(Boy).playRun(-1);
cc.tween(this.boyNode).to(1, { x: 500 }).call(() => {
this.boyNode.scaleX = 0.65;
this.boyNode.getComponent(Boy).playWave(-1);
this.btn_next.active = true;
}).start();
})
}).start()
}
}
playLocalAudio(audioName) {
const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
......@@ -291,26 +162,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
else if (event === cc.VideoPlayer.EventType.COMPLETED) {
this.videoCtrl.active = false;
this.node.getChildByName("bg").active = true;
cc.log("video completed");
this.boyNode.active = true;
this.vplayer.node.active = false;
if (this.WrongList.length > 0) {
this.initWorongLogic();
} else {
this.boyNode.getComponent(Boy).playtalk(-1);
this.playAudioByUrl(this.data.audio_url_end, () => {
this.boyNode.getComponent(Boy).playWave(-1);
this.btn_next.active = true;
})
}
pg.event.emit('play_video_end')
}
}
......
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