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 — updating the info text

  1. Insert a new method called UpdateInfoText.
    Method UpdateInfoText:Int()
    
  2. Set the text field of the text objects with their corresponding values.
    txtScore.SetText("Score: "+score)
    txtComets.SetText("Comets: "+cometCount)
    txtLevel.SetText("Level: "+levelNumber)
    txtLifes.SetText("Lifes: "+lifes)
    
  3. Close the method.
    Return 0
    End
    

What just happened?

Within the UpdateInfoText method, we update all of our UI text objects so they display the current values regarding score, the level number, how many lives are left, and also how many comets are left on the screen.

Starting a new game

There are two points where you want to start a new game by resetting some variables: at the beginning of the game, and after one game is over ...

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