Phaser for Beginners

Showing Game Over screen when running out of time

When the player runs out of time, we need to stop the game and show a game over screen. How can we make a game over screen?

Right, with another state.

Once the state has been added to the game, we will call it once the timer reaches zero. Look at decreaseTime method:

And now it’s just a matter of building the new state, with the “Game Over” text, the score and the message to tap to restart. Nothing new in the following code.

Play the game, and after a minute you should see something like this:

Ok, now tap to restart. You can’t. We have to write another couple of lines.

Download Source


Next Tutorial →

Restarting the game

← Previous Tutorial

Increasing difficulty by adding a timer