Time for action — creating info text objects

The next method will set up the two text objects for us:

  1. Inside the game class, add a new method called CreateInfoText.
    Method CreateInfoText:Int ()
    
  2. Create the txtScore text object from the font1 font object. Set it to the background layer.
    txtScore = eng.CreateText(font1,"Score: "+score,40,46)
    txtScore.SetLayer(layerBackGround)
    
  3. Repeat this with the txtFPS text object.
    txtFPS = eng.CreateText(font1,"FPS: "+999, eng.canvasWidth-45,46,2)
    txtFPS.SetLayer(layerBackGround)
    
  4. Close the method.
    Return 0
    End
    

What just happened?

To display some info text values, we have created two text objects with the CreateText method of fantomEngine. Later in the game, we will update them with the SetText method of each object.

The actual game screen

Now, let's create a method to compose the actual game screen.

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

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