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

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.67.235