Sign in to follow this  

Cleaning up on Game over

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)



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







Share this post

Link to post
Share on other sites

As far as I know Phaser is cleaning up itself when changing between game states (
What Phaser does not clean up is Audio - Music will still play when changing gameStates.

Share this post

Link to post
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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.