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 background screen

The game background will be just one image of some fields. It needs to be assigned to the background layer. That is all.

  1. Add the method CreateBackgroundScreen to the game class.
    Method CreateBackgroundScreen:Int()
    
  2. Set the default layer to layerBackground.
    eng.SetDefaultLayer(layerBackground)
    
  3. Create a local object that calls CreateImage. It will be displayed in the center of the canvas. After that, close the method.
    Local obj:= eng.CreateImage("background.png",cw/2,ch/2)
    Return 0
    End
    

What just happened?

With this new method, you have loaded the background image. For other platforms, you could also create some buttons to switch back to the title screen, but we will handle this differently.

Hope it won't ...

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