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

退出时清空异步

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