Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

5. Game #4, Chain Reaction > Time for action — creating a method to update the ...

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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial