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 layers for the game

To set up the layers for the game, we will use a method inside the game class, as follows:

  1. At first, add a new method header called CreateLayers.
    Method CreateLayers:Int()
    
  2. Create a new layer for the game objects and store it inside layerGame.
    layerGame = eng.CreateLayer()
    
  3. The top row of the game will hold some text objects. As the play field would cover them a little bit, we will move the game layer a little bit downwards.
    layerGame.SetPos((eng.canvasWidth-11*64)/2+32,+100)
    
  4. Now, create another layer for the title screen and store it inside layerTitle. After that, close this method.
    layerTitle = eng.CreateLayer()
    Return 0
    End
    

What just happened?

This time, we only created layers for the game objects and ...

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