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 — composing the background screen

Time for action — composing the background screen

In the background screen, you will see a grid for all the gems. On the right side of the grid, you will also see the current score displayed, along with the time which is remaining to play this game.

  1. Insert a new method called CreateBackgroundScreen into the game class.
    Method CreateBackgroundScreen:Int ()
    
  2. Set the default layer for this method.
    eng.SetDefaultLayer(layerBackground )
    
  3. Start two new FOR loops—one for the rows (x) and one for the columns (y).
    For Local y:Int = 1 To rows
    For Local x:Int = 1 To columns
    

    In the next few pages, you will see the integer value 64 used many times. It is the length of the edge of all sprites that we will load.

  4. Now, load the grid sprite from the atlas image. The position will be set depending on the x and y values. Close both FOR loops.
    Local obj := eng.CreateImage(atlas,0,0,64,64,x*64,y*64)
    Next
    Next
    

  

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