Commit a9260f8f authored by 范雪寒's avatar 范雪寒

fix:timeout

parent b7b04aa8
...@@ -16,6 +16,8 @@ cc.Class({ ...@@ -16,6 +16,8 @@ cc.Class({
// 生命周期 onLoad // 生命周期 onLoad
onLoad() { onLoad() {
this._timeoutIds = [];
this._intervalIds = [];
this.initSceneData(); this.initSceneData();
this.initSize(); this.initSize();
}, },
...@@ -372,9 +374,9 @@ cc.Class({ ...@@ -372,9 +374,9 @@ cc.Class({
createStarAni() { createStarAni() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.showStar(); this.showStar();
setTimeout(() => { this._timeoutIds.push(setTimeout(() => {
resolve(''); resolve('');
}, 500); }, 500));
}); });
}, },
createFireworkAni() { createFireworkAni() {
...@@ -395,9 +397,9 @@ cc.Class({ ...@@ -395,9 +397,9 @@ cc.Class({
cc.find('Canvas/RibbonNodeBase').children, cc.find('Canvas/RibbonNodeBase').children,
cc.v2(600, -400), cc.v2(-200, 1000), 200, 200 cc.v2(600, -400), cc.v2(-200, 1000), 200, 200
); );
setTimeout(() => { this._timeoutIds.push(setTimeout(() => {
resolve(''); resolve('');
}, 1000); }, 1000));
}); });
}, },
playSFX(name) { playSFX(name) {
...@@ -578,14 +580,14 @@ cc.Class({ ...@@ -578,14 +580,14 @@ cc.Class({
this.playSFX("mao_choice").then(() => { this.playSFX("mao_choice").then(() => {
this.catNormal(); this.catNormal();
}); });
setTimeout(() => { this._timeoutIds.push(setTimeout(() => {
let items = this._cardLayout.children; let items = this._cardLayout.children;
let item = items.filter(it => { return it.data.cardId == 0 })[0]; let item = items.filter(it => { return it.data.cardId == 0 })[0];
pg.view.visible(pg.view.find(item, 'box'), true); pg.view.visible(pg.view.find(item, 'box'), true);
this._cantouch = true; this._cantouch = true;
this._successItems.push(item); this._successItems.push(item);
resolve(''); resolve('');
}, 300); }, 300));
}); });
}, },
catFinish() { catFinish() {
...@@ -607,5 +609,16 @@ cc.Class({ ...@@ -607,5 +609,16 @@ cc.Class({
catNormal() { catNormal() {
let cat = pg.view.find(this, "cat"); let cat = pg.view.find(this, "cat");
pg.view.playDragonBone(cat, "normal"); pg.view.playDragonBone(cat, "normal");
} },
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
}); });
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