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 — composing the game screen

We create the background screen in one batch and method. You will easily be able to add more stuff to it, if you need to:

  1. Add the method CreateBackgroundScreen to the game class.
    Method CreateBackgroundScreen:Int()
    
  2. For the single-colored background, create a new box object, assign it to the background layer, and set its color to a dark blue.
    Local box:ftObject = eng.CreateBox(cw-20,ch-20,cw/2,ch/2)
    box.SetLayer(layerBackGround)
    box.SetColor(0,0,100)
    
  3. Next, add a BACK button at the top-center of the canvas.
    CreateTextButton(font1, "Back",cw/2,46, btnBack, layerBackGround)
    
  4. To display the game score and the FPS value, create two text objects and assign them to the background layer.
    txtScore = eng.CreateText(font1,"Score: ...

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