Commit 4f4ce7d2 authored by limingzhe's avatar limingzhe

fix: debug

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