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

fix:timeout

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