O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — showing the "game over" screen

We will display Game Over by following the ensuing steps:

  1. Create a new method called ShowGameOver inside the game class.
    Method ShowGameOver:Int()
    
  2. Set the game mode to gmGameOver and activate layers with it.
    gameMode = gmGameOver
    ActivateLayer(gameMode)
    
  3. Set the final score text object with the score value. Then, close the method.
    txtFinalScore.SetText("SCORE: "+score)
    Return 0
    End
    

What just happened?

This method will take care of showing the 'game over' screen.

Showing the menu screen

Usually, you don't need an extra method to show a layer, but if you do this in multiple places in your code, it makes sense to add a method for it and just call it. It helps in reducing the length of your code by removing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required