From 8efad4357f5dcea4bf9467ce95b02f6e0d22f4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Wed, 31 Oct 2018 23:17:38 +0900 Subject: [PATCH] Fix: time bug --- src/game/mouse/grilled_meat/game.js | 46 +++++++++++++++-------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/game/mouse/grilled_meat/game.js b/src/game/mouse/grilled_meat/game.js index 3dd3895..7c733ea 100644 --- a/src/game/mouse/grilled_meat/game.js +++ b/src/game/mouse/grilled_meat/game.js @@ -169,39 +169,33 @@ var Game = { startGame: function() { this.playingStageNo = 1; - // this.leftTimeSec = 0; // INIT_LEFT_TIME_MIN * 60; - - // this.score = 0; - // this.updateScore(); this.startStage(); }, startStage: function() { var bonusTime = this.getBonusTime(); - if(this.playingStageNo == 1) - this.showStageNotice(this.playingStageNo + "단계 시작 (제한 시간 : " + bonusTime + "초)"); - else if(bonusTime == 0) + this.showStageNotice(this.playingStageNo + "단계 시작 (제한 시간 : " + bonusTime + "초)"); + + this.clearedMeatCount = 0; + this.activatedMeatCount = this.getStageMeatCount(); + this.serveMeats(); + + this.stageTimer.start(); + }, + + startNextStage: function() { + var bonusTime = this.getBonusTime(); + if(bonusTime == 0) this.showStageNotice(this.playingStageNo + "단계 시작"); else this.showStageNotice(this.playingStageNo + "단계 시작 (보너스 +" + bonusTime + "초)"); - // this.leftTimeSec += bonusTime; - this.stageTimer.start(); - // this.stageTimer.add(bonusTime); - // this.updateLeftTime(); - - // if(this.playingStageNo == 1) - // this.timeEvent = game.time.events.loop(1000, this.updateLeftTime, this); - - this.activatedMeatCount = this.getStageMeatCount(); this.clearedMeatCount = 0; + this.activatedMeatCount = this.getStageMeatCount(); this.serveMeats(); }, - startNextStage: function() { - }, - setClickEnable: function(value) { this.isEnableClick = value; @@ -249,7 +243,7 @@ var Game = { showStageNotice: function(text) { this.stageNoticeText.alpha = 0; this.stageNoticeText.text = text; - this.animateTextAlpha(this.stageNoticeText, 1, 0, 1000, Phaser.Easing.Linear.None); + this.animateTextAlpha(this.stageNoticeText, 1, 0, Phaser.Timer.SECOND * 2, Phaser.Easing.Linear.None); }, @@ -341,7 +335,7 @@ var Game = { this.showStageNotice(this.playingStageNo + "단계 완료"); this.playingStageNo++; - var startStageTimeEvent = game.time.events.add(Phaser.Timer.SECOND * 1, this.startStage, this); + var startStageTimeEvent = game.time.events.add(Phaser.Timer.SECOND * 1, this.startNextStage, this); this.gameTimeEvents[this.gameTimeEvents.length + 1] = startStageTimeEvent; }, @@ -355,6 +349,14 @@ var Game = { gameOver: function() { + for(var i = 0; i < this.gameTimeEvents.length; i++) { + game.time.events.remove(this.gameTimeEvents[i]); + } + this.gameTimeEvents = []; + + var gameOverText = new GameOverText(); + + game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this); }, goResult: function() { @@ -371,7 +373,7 @@ Game.INIT_LEFT_TIME_MIN = 2; Game.MAX_MEAT_COUNT = 20; -Game.HEAT_PLATE_HANDLE_WIDTH = 440; +Game.HEAT_PLATE_HANDLE_WIDTH = 440; Game.HEAT_PLATE_START_OFFSET_Y = 80; Game.HEAT_PLATE_HEIGHT = 220;