Time for action — creating text buttons

This new helper method will be added to the game class:

  1. Insert a new class called CreateTextButton. Its parameters are a font object, the text, its position, button ID, and the layer that the button is added to.
    Method CreateTextButton:ftObject (font:ftFont, txt:String, xp:Int, yp:Int, id:Int, layer:ftLayer)
    
  2. Create a new next object.
    Local but:ftObject = eng.CreateText(font,txt,xp,yp,1)
    
  3. It its tag with the ID and the touch mode to a rectangular hit test.
    but.SetTag(id)
    but.SetTouchMode(2)
    
  4. Now, set the layer and close the method.
    but.SetLayer(layer)
    Return but
    End
    

What just happened?

With this method, we can easily add text buttons with one line of code. It is all about being more efficient when you develop games, because even your spare time is money!

The background screen as usual

This is composed of different objects. We will have a nice single-colored background and a few text objects.

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

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