JavaScript Introducing JavaScript Finishing the Game Wrapping It Up

Thomas Goepfert
Thomas Goepfert
1,732 Points

End game

I added a lifecounter to the game and it works great, even has 'you lose' text. But after losing the game my character can still move around and collect coins. How do I make the game stop completely? Here is my workspace-https://teamtreehouse.com/workspaces/40804771

6 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 47,480 Points

There is a player.destroy() method that causes the player to disappear. I added that after the 'you lose' message is updated, along with changing the background color.

Thomas Goepfert
Thomas Goepfert
1,732 Points

That worked! Thanks a lot all for your help.

Link gives page not found. Can you update the link?

KRIS NIKOLAISEN
KRIS NIKOLAISEN
Pro Student 47,480 Points

If you want to share a workspace you will have to create a snapshot. It is the camera icon in the upper right corner.

Hmm... weird. Can you take a snapshot instead? On the top right corner there a camera to take a snapshot of your workspace.

You can place this under both win and lost conditional statements.

player.body.velocity.x = 0;