O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — creating text buttons

To create text buttons, we will reuse some code that we have created in a previous chapter.

Copy the CreateTextButton method from Chapter 4, Game #3, CometCrusher, into the game class.

Method CreateTextButton:ftObject (font:ftFont, txt:String, xp:Int, yp:Int, id:Int, layer:ftLayer)
Local but:ftObject = eng.CreateText(font,txt,xp,yp,1)
but.SetTag(id)
but.SetTouchMode(2)
but.SetLayer(layer)
Return but
End

What just happened?

Reusing code is a good thing. Why reinvent the wheel several times. That is why we use the fantomEngine framework in the first place, isn't it?

The menu screen

Now that we have a method to create text buttons, we can define the menu screen.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required