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 and you want to start a new one.

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

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