rickydamta Posted November 19, 2015 Share Posted November 19, 2015 Hi everyoneDo you know a code that can restart completely the game?Thanks Link to comment Share on other sites More sharing options...
joshbivens Posted November 19, 2015 Share Posted November 19, 2015 http://phaser.io/examples/v2/games/invaders is helpful. Especiallyfunction restart () { // A new level starts //resets the life count lives.callAll('revive'); // And brings the aliens back from the dead aliens.removeAll(); createAliens(); //revives the player player.revive(); //hides the text stateText.visible = false;} Link to comment Share on other sites More sharing options...
vohogames Posted November 19, 2015 Share Posted November 19, 2015 Once the game is instantiated, you can change states. Is it what you are asking for? as an example VohoGame.game = new Phaser.Game(VohoGame.gameOptions.gameWidth, VohoGame.gameOptions.gameHeight, Phaser.CANVAS, "gamecanvas"); VohoGame.game.state.add("Boot", VohoGame.Boot);VohoGame.game.state.add("Preload", VohoGame.Preload);VohoGame.game.state.add("GameTitle", VohoGame.GameTitle);VohoGame.game.state.add("GameStart", VohoGame.GameStart);VohoGame.game.state.add("GameOver", VohoGame.GameOver);VohoGame.game.state.add("GameSuccess", VohoGame.GameSuccess);/* Start the game with Boot state */VohoGame.game.state.start("Boot"); Link to comment Share on other sites More sharing options...
rickydamta Posted November 19, 2015 Author Share Posted November 19, 2015 No I want to reset the position of all the sprites,i tried withplayer.resetPosition();but it does not work Link to comment Share on other sites More sharing options...
Get_Bentley Posted November 19, 2015 Share Posted November 19, 2015 Are you talking about restarting a level? Like if you die it resets the level? If you are using states you can do something like // In updatethis.game.physics.collide.(this.enemy, this.player, this.killPlayer, null, this) if (this.enemy && this.player.collide) { this.killPlayer();}, // In game statekillPlayer: function() {this.player.kill(); game.state.start('Game');}; Not sure if this is what you are asking but in this case if a player and enemy collide it kills the player and restarts the 'Game' State. This is if you are using states. pog and Skeptron 2 Link to comment Share on other sites More sharing options...
rickydamta Posted November 19, 2015 Author Share Posted November 19, 2015 Thanks bentley Link to comment Share on other sites More sharing options...
Get_Bentley Posted November 20, 2015 Share Posted November 20, 2015 No problem man! Always stoked when I can help out. Link to comment Share on other sites More sharing options...
Recommended Posts