Jump to content

On restart, life counter goes down by one


joshbivens
 Share

Recommended Posts

I added a 'restart' icon that runs a restart function when clicked, but if you click it at any time before the 'Game Over' screen, it restarts just fine but after a second the lives counter goes down by one. The only delay timer I have is the Webfonts loader, so I'm confused.

 

The project in question: https://github.com/joshbivens/breakout-pipboy

Thanks for your time!

Link to comment
Share on other sites

I suspect this is due to the fact that you don't restart a game state, you manually 'restart' everything. So maybe the ball from your previous game session still does exist, goes out of bounds and causes you to lose a life. You should use a Game State, and basically just restart it. The code would be much easier, shorter, and guaranteed to work.

Link to comment
Share on other sites

I suspect this is due to the fact that you don't restart a game state, you manually 'restart' everything. So maybe the ball from your previous game session still does exist, goes out of bounds and causes you to lose a life. You should use a Game State, and basically just restart it. The code would be much easier, shorter, and guaranteed to work.

 

Thank you very much. 

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...