From 7f14cd5720c60e06fa323649d07045c030f7739a Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sat, 12 Jul 2014 23:57:46 -0700 Subject: [PATCH] Game over screen can start a new game (but it has bugs....) --- moonlight/src/GameStates.js | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/moonlight/src/GameStates.js b/moonlight/src/GameStates.js index cd9d581..948e39e 100644 --- a/moonlight/src/GameStates.js +++ b/moonlight/src/GameStates.js @@ -469,6 +469,18 @@ GameState.prototype.update = function() GameState.prototype.shutdown = function() { this.aiSprites.setAll('ready_to_update', false); + this.aiSprites.forEach(function(x) { + if ( isSet(x.awareness_timer) == true ) + x.awareness_timer.stop(); + if ( isSet(x.glint_timer) == true ) + x.glint_timer.stop(); + if ( isSet(x.conversation_timer) == true ) + x.conversation_timer.stop(); + if ( isSet(x.rotation_timer) == true ) + x.rotation_timer.stop(); + if ( isSet(x.timer) == true ) + x.timer.stop(); + }, this); this.aiSprites.destroy(); this.aiSprites = null; this.uigroup.destroy(); @@ -594,7 +606,36 @@ var EndScreen = function(game) { EndScreen.prototype.create = function() { this.gameOverText = game.add.image((640/2), - (480/2), + 100, 'gameover'); this.gameOverText.anchor.setTo(0.5, 0.5); + this.startGameButton = game.add.button((640 / 2), + 200, + 'newgamebtn', + this.startGameClicked, + this, + 1, + 0); + this.startGameButton.anchor.setTo(0.5, 0.5); + this.creditsButton = game.add.button((640 / 2), + 300, + 'creditsbtn', + this.creditsClicked, + this, + 1, + 0); + this.creditsButton.anchor.setTo(0.5, 0.5); +} + +EndScreen.prototype.startGameClicked = function() +{ + this.startGameButton.destroy(); + this.creditsButton.destroy(); + this.gameOverText.destroy(); + game.state.start('game', true, false); +} + +EndScreen.prototype.creditsClicked = function() +{ + console.log("Roll the credits dumbass"); }