From 99e273f7405adc4ddfd0ccb89df2de346fe330b4 Mon Sep 17 00:00:00 2001 From: Juraj Michalek Date: Wed, 30 Dec 2015 10:14:50 +0100 Subject: [PATCH] delay displaying next button --- js/app/game-state.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/js/app/game-state.js b/js/app/game-state.js index 7ee9efa..d82c0c9 100644 --- a/js/app/game-state.js +++ b/js/app/game-state.js @@ -336,13 +336,24 @@ state.checkCollision = function () { } if (((Math.round(positionX/64) == Math.round(this.finishMarker.x/64) )) && (Math.round(positionY/64) == Math.round(this.finishMarker.y/64))) { - this.stageState = 'complete'; - this.myButton.text = 'Next' - this.addChild( this.myButtonSprite ); - this.addChild( this.myButton ); - - this.character.physics.velocity.x = 0; - this.character.physics.velocity.y = 0; + this.stageComplete(); } } + +state.displayCongratulation = function() { + this.myButton.text = 'Next' + this.addChild( this.myButtonSprite ); + this.addChild( this.myButton ); +} + +state.stageComplete = function() { + this.stageState = 'complete'; + + this.timer = this.game.time.clock.createTimer('time', 1, 1, true); + + this.timer.createTimerEvent( Kiwi.Time.TimerEvent.TIMER_STOP, this.displayCongratulation, this ); + + this.character.physics.velocity.x = 0; + this.character.physics.velocity.y = 0; +}