kmp Posted November 15, 2014 Share Posted November 15, 2014 This is a simple question: when you switch from one game state to another are you supposed to clean up - stop timers, destroy sprites etcetera? I'm writing my first phaser game. I have a game state and a game over state. Obviously I switch from the game state to the game over state when the game is over and from game over I switch back to the game state if the user wants to play again. Just switching like this seems to work perfectly: if (this.sprite.y < 0) { this.game.state.start('GameOver'); } But the game state has timers and sprites - should I destroy them before switching? Am I worried about nothing? Does Phaser do the necessary tidying up? Thanks in advance Ken Link to comment Share on other sites More sharing options...
Sam Posted November 15, 2014 Share Posted November 15, 2014 As far as I know Phaser is cleaning up itself when changing between game states (this.game.state.start).What Phaser does not clean up is Audio - Music will still play when changing gameStates. Link to comment Share on other sites More sharing options...
kmp Posted November 16, 2014 Author Share Posted November 16, 2014 Great. That's just what I wanted to hear Link to comment Share on other sites More sharing options...
Recommended Posts