crffty Posted December 29, 2016 Share Posted December 29, 2016 hi. I'm having a bit of a brain dead moment!!! I need a super simple if button is clicked restart the game state in the pause menu. (Im using the game pause as a cheat end game screen) this is the function I'm working on - all I need is to be able to click 'rePlay'. endGame: function() { this.game.paused = true; this.game.add.text(this.game.world.centerX - 150, this.game.world.centerY - 100, "game over", { font: "60px Raleway"} ); // place the reset button this.rePlay = game.add.sprite(this.game.world.centerX - 150, this.game.world.centerY + 100, 'rePlay'); this.rePlay.anchor.setTo(0.5, 0.5); // if replay is pushed --- this if (this.rePlay.event) { game.state.start(game.state.current);; } } Link to comment Share on other sites More sharing options...
XekeDeath Posted December 29, 2016 Share Posted December 29, 2016 // Enable input on the button... this.rePlay.inputEnabled = true; // Attach a function to the input down ( click/tap) this.rePlay.events.onInputDown.add(function() { this.game.state.start('name of the current state'); }, this); Link to comment Share on other sites More sharing options...
crffty Posted January 3, 2017 Author Share Posted January 3, 2017 I've tried this but its still not doing anything. not even a error. endGame: function() { this.game.paused = true; this.game.add.text(this.game.world.centerX - 150, this.game.world.centerY - 100, "game over", { font: "60px Raleway"} ); // place the reset button this.rePlay = game.add.sprite(this.game.world.centerX - 150, this.game.world.centerY + 100, 'rePlay'); this.rePlay.anchor.setTo(0.5, 0.5); // Enable input on the button... this.rePlay.inputEnabled = true; // Attach a function to the input down ( click/tap) this.rePlay.events.onInputDown.add(function() { this.game.state.start('game'); }, this); } i believe its to do with the game being paused ( pretty sure ) so how do i un-pause the game? this.game.paused = false; doesn't seem to do anything Link to comment Share on other sites More sharing options...
Recommended Posts