Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Game #8, Treasure Chest > Time for action — creating layers for the game

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


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint