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

fix: timeout

parent f22f9236
......@@ -32,6 +32,8 @@ var game = cc.Class({
},
ctor: function () {
this._timeoutIds = [];
this._intervalIds = [];
game.inst = this;
g.game = game;
},
......@@ -146,9 +148,9 @@ var game = cc.Class({
.start();
}
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
this.UpdataUi();
}, 1000);
}, 1000));
}
},
......@@ -156,9 +158,9 @@ var game = cc.Class({
finish() {
this.playLionDragon("normal")
this.playCatDragon("finish")
setTimeout(() => {
this._timeoutIds(setTimeout(() => {
g.speaker.inst.playEffect(g.enum.E_Audio.CatComplete);
}, 500)
}, 500));
},
//检测放到哪个节点底下
......@@ -327,4 +329,15 @@ var game = cc.Class({
this.onBtnReStart();
}
},
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
});
......@@ -15,6 +15,8 @@ var eff_well = cc.Class({
ctor: function () {
eff_well.inst = this;
g.eff_well = eff_well;
this._timeoutIds = [];
this._intervalIds = [];
},
//显示特效
......@@ -23,8 +25,19 @@ var eff_well = cc.Class({
this.eff_welldown.play();
//播放撒花音效
g.speaker.inst.play_congratulation();
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
this.node.active = false;
}, 2000)
}
}, 2000));
},
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
});
......@@ -21,6 +21,8 @@ cc.Class({
},
start: function () {
this._timeoutIds = [];
this._intervalIds = [];
this.node.on(cc.Node.EventType.TOUCH_START, this.touchBegan, this);
this.node.on(cc.Node.EventType.TOUCH_MOVE, this.touchMove, this);
this.node.on(cc.Node.EventType.TOUCH_END, this.touchEnd, this);
......@@ -52,6 +54,7 @@ cc.Class({
});
}
}, 1000)
this._intervalIds.push(this.timer);
this.isMove = false;
this.deltaPos = this.node.x + this.node.y;
},
......@@ -136,7 +139,7 @@ cc.Class({
//先播放错误声音
g.speaker.inst.playEffect(g.enum.E_Audio.Right);
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
g.game.inst.playCatDragon("right");
let num = g.utils.randFromTo_Int(g.enum.E_Audio.CatRight1, g.enum.E_Audio.CatRight2);
......@@ -149,7 +152,7 @@ cc.Class({
g.data_mgr.quesId += 1;
g.game.inst.resetQues();
}
}, 500)
}, 500));
// g.data_mgr.nowNum -= 1;
// if (g.data_mgr.nowNum == 0) {
......@@ -185,7 +188,7 @@ cc.Class({
.to(0.15, { scaleY: 1.1, scaleX: 0.9 })
.to(0.1, { scaleY: 1, scaleX: 1 })
.start()
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
//回到原来的位置
this.node.x = 0;
this.node.y = 0;
......@@ -198,7 +201,7 @@ cc.Class({
});
g.game.inst.playCatDragon("wrong");
g.game.inst.playLionDragon("normal");
}, 500)
}, 500));
},
//触摸取消
......@@ -230,9 +233,9 @@ cc.Class({
onBtnRotate: function () {
var scaleX = this.node.scaleY;
this._isRotate = true;
setTimeout(() => {
this._timeoutIds.push(setTimeout(() => {
this._isRotate = false;
}, 600)
}, 600));
cc.tween(this.node)
.to(0.3, { scaleX: 0 })
......@@ -274,4 +277,15 @@ cc.Class({
node.scaleX *= maxSize;
node.scaleY *= maxSize;
},
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
});
......@@ -162,6 +162,7 @@ g.data_mgr = {
g.game.inst.hintPlay();
}
}, 1000)
g.game.inst._intervalIds.push(this.timer);
g.game.inst.isLoadEnd = true;
},
......
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