Jump to content

Cleaning up on Game over


kmp
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...