Commit 4f4ce7d2 authored by limingzhe's avatar limingzhe

fix: debug

parent 1207da21
......@@ -29,8 +29,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAnima() {
}
isDestroy;
protected onDestroy(): void {
this.isDestroy = true;
clearTimeout(this.timeOut);
clearInterval(this.intervalId);
cc.audioEngine.setEffectsVolume(1);
}
onLoadEnd() {
......@@ -112,6 +116,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
async randomPopo() {
const createPopo = async () => {
await asyncDelay(RandomInt(0, 20));
if (this.isDestroy) {
return;
}
const rType = Math.random()<0.5?1:2; // 1: 小泡泡,2:大泡泡
const node = getSprNode(rType==1?"popo_sm":"popo_big");
node.y = 0-(this.node.height / 2) - 260;
......@@ -131,7 +138,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
ppArr.push(createPopo());
}
await Promise.all(ppArr);
if (this.isDestroy) {
return;
}
await this.randomPopo();
if (this.isDestroy) {
return;
}
}
initEvent() {
this.btn_laba.on(cc.Node.EventType.TOUCH_END, this.onLaba, this);
......@@ -171,6 +184,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.page = index;
this.updateTop();
this.playLocalAudio("fanye", 0.2).then(() => {
if (this.isDestroy) {
return;
}
this.playQuestionAudio();
});
console.log("idx:" + index);
......@@ -200,6 +216,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (this.intervalId) clearInterval(this.intervalId);
this.stop = false;
this.intervalId = setInterval(() => {
if (this.isDestroy) {
return;
}
count++;
// btn_laba1.active = count % 2 == 0;
btn_laba2.active = count % 2 == 1;
......@@ -210,6 +229,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}, 150)
pg.audio.playAudioByUrl(audio).then((audioId) => {
if (this.isDestroy) {
return;
}
this.stop = true;
btn_laba1.active = true;
btn_laba2.active = true;
......@@ -231,7 +253,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.isRecording = true;
btn_recording.active = true;
recording_count.fillRange = 0;
cc.tween(recording_count).to(120, { fillRange: -1 }).call(() => { recording_count.fillRange = 0; this.recordStop(); }).start();
cc.tween(recording_count).to(120, { fillRange: -1 }).call(() => {
if (this.isDestroy) {
return;
}
recording_count.fillRange = 0; this.recordStop(); }).start();
let text = "";
if (Game.getIns().lists[this.page].text) {
......@@ -266,6 +292,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
const time = cc.audioEngine.getDuration(audioId);
cc.tween(recording_count).to(time, { fillRange: -1 }).call(() => { recording_count.fillRange = 0; }).start();
}).then(() => {
if (this.isDestroy) {
return;
}
this.btn_stop.active = false;
this.btn_play.active = true;
});
......@@ -299,6 +328,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (this.timeOut) clearTimeout(this.timeOut);
this.timeOut = setTimeout(() => {
if (this.isDestroy) {
return;
}
let index = this.page_view.getComponent(cc.PageView).getCurrentPageIndex();
this.page_view.getComponent(cc.PageView).scrollToPage(index + 1, 0.1);
}, 2000);
......@@ -326,6 +358,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (this.autoPlay == 0) return;
let time = audioId ? 1000 : 3000;
this.timeOut = setTimeout(() => {
if (this.isDestroy) {
return;
}
let index = this.page_view.getComponent(cc.PageView).getCurrentPageIndex();
this.page_view.getComponent(cc.PageView).scrollToPage(index + 1, 0.1);
}, time);
......@@ -344,6 +379,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
const group = cc.instantiate(this.layout_pic);
let pic = cc.find("pic", group);
await pg.view.setNetImg(pic, question.pic_url, { w: 943, h: 1024 }, true);
if (this.isDestroy) {
return;
}
cc.find("pic2", group).active = false;
// 等首图加载完成后 隐藏加载进度条
if (index == 0) {
......@@ -389,6 +427,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.layout_loading.active = false;
this.recordEndView.active = true;
asyncDelay(2).then(() => {
if (this.isDestroy) {
return;
}
this.onHideEnd();
});
let overall = res.result.overall;
......@@ -474,5 +515,5 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log(str);
// }
}
}
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