Time for action — creating a method to update the text information

To update these text objects, we will create the UpdateInfoText method. Each text object has a text field that stores the text string value. The content of this field will be drawn on the screen.

  1. Add a new method called UpdateInfoText to the game class.
    Method UpdateInfoText:Int()
    
  2. Set the text fields of both objects corresponding to their purpose.
    txtScore.SetText("Score: "+score)
    txtFPS.SetText("FPS: "+fps)
    
  3. Close the method.
    Return 0
    End
    

What just happened?

Since we created a separate method to update the info text objects, we can call it at any time we wish. Later on, we will do this in the OnUpdate event on the game class, but the OnRender event would be good, too.

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

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