Commit 561ced30 authored by Friends233's avatar Friends233

修改定时器

parent aa07dd0d
......@@ -81,6 +81,8 @@ export default class GameScene extends cc.Component {
/** 加速倍率 */
speedMultiplier = 1
timer = null
protected onLoad(): void {
// loadGameResources()
......@@ -183,7 +185,8 @@ export default class GameScene extends cc.Component {
this.startGameCountAni(() => {
this.isStartGame = true
cc.find('clipMask/clipWrp', this.node).getComponent(cc.Animation).play()
this.schedule(this.startCd, 1)
// this.schedule(this.startCd, 1)
this.timer = setInterval(() => this.startCd(), 1000)
})
}
......@@ -301,6 +304,7 @@ export default class GameScene extends cc.Component {
this.isGameOver = true
this.setClipState(CLIP_STATE.GAME_OVER)
this.unschedule(this.startCd)
window.clearInterval(this.timer)
exportEvent.fire(CUSTOM_EVENT.GAME_OVER, {
...this.gameConfig.LevelInfo[this.actLevel],
score: this.starNum,
......@@ -323,6 +327,7 @@ export default class GameScene extends cc.Component {
this.setLable('cdIcon/cd', `0s`)
this.gameOver()
this.unschedule(this.startCd)
window.clearInterval(this.timer)
return
}
this.countDown = cd
......@@ -331,6 +336,7 @@ export default class GameScene extends cc.Component {
protected onDestroy(): void {
this.unschedule(this.startCd)
window.clearInterval(this.timer)
}
/** 刷新关卡信息 */
......@@ -352,6 +358,7 @@ export default class GameScene extends cc.Component {
this.updateGameProc()
this.unschedule(this.startCd)
window.clearInterval(this.timer)
this.setLable('cdIcon/cd', `${this.countDown}s`)
}
......@@ -372,6 +379,7 @@ export default class GameScene extends cc.Component {
if (this.starNum >= this.levelObjectives) {
this.isStartGame = false
this.unschedule(this.startCd)
window.clearInterval(this.timer)
exportEvent.fire(CUSTOM_EVENT.PASS_LEVEL, {
...this.gameConfig.LevelInfo[this.actLevel],
score: this.starNum,
......@@ -386,13 +394,15 @@ export default class GameScene extends cc.Component {
const nextLevel = this.actLevel + 1
this.isStartGame = true
this.unschedule(this.startCd)
window.clearInterval(this.timer)
if (nextLevel >= this.gameConfig.LevelInfo.length) { // 已通关
this.gameOver()
return
}
this.refreshLevelInfo(nextLevel)
this.refreshStageProps()
this.schedule(this.startCd, 1)
// this.schedule(this.startCd, 1)
this.timer = setInterval(() => this.startCd(), 1000)
}
/** 更新游戏进度条信息 */
......
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