Commit 26e38797 authored by 李维's avatar 李维

退出时清空异步

parent d631d85a
......@@ -26,6 +26,9 @@ export default class GameLogic_JJ_Game_10 {
m_isPlayingAudio = false;
m_sysIntervalId = null;
m_setTimeoutIds = [];
m_setIntervalIds = [];
constructor(formData, systemOption) {
this.g_systemOption = systemOption;
this.g_imageResList = this.g_systemOption.imageResList;
......@@ -151,9 +154,10 @@ export default class GameLogic_JJ_Game_10 {
let a = btn_lion.node.getComponent(dragonBones.ArmatureDisplay)
a.playAnimation(aniName, 1);
setTimeout(() => {
this.m_setTimeoutIds.push(setTimeout(() => {
a.playAnimation(aniName, -1);
}, 3200);
}, 3200))
}
......@@ -178,6 +182,7 @@ export default class GameLogic_JJ_Game_10 {
currentIdx++;
speakers[currentIdx%num].active = true;
}, 200);
this.m_setIntervalIds.push(intervalId)
}
btn_speaker.stopAni = ()=>{
......@@ -319,7 +324,9 @@ export default class GameLogic_JJ_Game_10 {
}
}
})
}, 30)
}, 30);
this.m_setIntervalIds.push(this.m_sysIntervalId)
}
initStar() {
......@@ -428,13 +435,13 @@ export default class GameLogic_JJ_Game_10 {
bubb.node.getChildByName("image").active = false;
for(let i=0; i<8; i++) {
_p.push(new Promise((resolve,reject) => {
setTimeout(() => {
this.m_setTimeoutIds.push(setTimeout(() => {
if(i>1) {
bubb.node.getChildByName(`bubble_ani (${i})`).active = false;
}
bubb.node.getChildByName(`bubble_ani (${i+1})`).active = true;
resolve()
}, 30 * i);
}, 30 * i));
}))
}
return Promise.all(_p)
......@@ -569,10 +576,10 @@ export default class GameLogic_JJ_Game_10 {
this.m_bubblesAll = this.save;
return new Promise((resolve, reject)=>{
setTimeout(() => {
this.m_setTimeoutIds.push(setTimeout(() => {
resolve();
this.enableClick("DestroyBubbles")
}, 1100);
}, 1100))
})
}
......@@ -613,12 +620,12 @@ export default class GameLogic_JJ_Game_10 {
bubble.move.vX = vArr[count%4].vX
bubble.move.vY = vArr[count%4].vY
count++;
setTimeout(() => {
this.m_setTimeoutIds.push(setTimeout(() => {
this.g_cartoon.playAudio("出现")
this.g_cartoon.tweenChange(bubble.node, {scale: this.m_maxScale, x: bubble.move.x, y: bubble.move.y}, 3, _=>{
resolve()
})
}, 200 * index);
}, 200 * index))
})
pAll.push(_p)
}
......@@ -682,9 +689,9 @@ export default class GameLogic_JJ_Game_10 {
asyncDelay(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
this.m_setTimeoutIds.push(setTimeout(() => {
resolve();
}, time * 1000);
}, time * 1000))
})
}
......@@ -863,6 +870,20 @@ export default class GameLogic_JJ_Game_10 {
// Common function
onDestroy() {
console.log("onDestroy")
this.m_setTimeoutIds.forEach(id=>{
if(id) {
clearTimeout(id)
}
})
this.m_setIntervalIds.forEach(id=>{
if(id) {
clearInterval(id)
}
})
}
maskLayer = null;
initMaskLayer() {
const parentNode = this.g_cartoon.getNodeByPath("MaskLayer")
......
......@@ -108,6 +108,10 @@ cc.Class({
})
},
onDestroy() {
this.gameLogic.onDestroy();
},
getData(func) {
if (window && window.courseware) {
window.courseware.getData(func, 'scene');
......
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