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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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