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, you need to add another method.

  1. Add the method CreateLayers into the game class.
    Method CreateLayers:Int()
    
  2. Store the default layer in the layerBackground field.
    layerBackground = eng.GetDefaultLayer()
    
  3. Then, create new layers for all the ones we have defined in the data class.
    layerGame = eng.CreateLayer()
    layerGFX = eng.CreateLayer()
    layerGameOver = eng.CreateLayer()
    layerMenu = eng.CreateLayer()
    layerScore = eng.CreateLayer()
    layerTitle = eng.CreateLayer()
    
  4. Close the method.
    Return 0
    End
    

What just happened?

Again, we have implemented a method to create all the layers we need in the game.

Our beloved play field—the background screen

Now, we will define all the elements of the background ...

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