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

Remember that the game screen is composed of one background image, two text objects, and two button objects:

  1. To compose the screen, add a method called CreateGameScreen in the game class.
    Method CreateGameScreen:Int()
    
  2. Load the background image into a local object, as we don't need to access it separately later on. Set its layer to layerBackGround.
    Local ts:ftObject = eng.CreateImage("CR_GameScreen.png",eng.canvasWidth/2, eng.canvasHeight/2)
    ts.SetLayer(layerBackGround)
    
  3. Now create the RESET button at a location where it is drawn on the background image.
    CreateButton(180,60,130,eng.canvasHeight-50, btnReset, layerBackGround)
    
  4. Repeat this for the EXIT button and then close the method.
    CreateButton(180,60,eng.canvasWidth-130,eng.canvasHeight-50, ...

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