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 the "game over" screen

Time for action — creating the "game over" screen

In the next method, a screen will be created and will display Game Over and the score that the player had reached.

  1. Insert the method CreateGameOverScreen into the game class.
    Method CreateGameOverScreen:Int ()
    
  2. Set the default layer to layerGameOver.
    eng.SetDefaultLayer(layerGameOver)
    
  3. Create a blue box.
    Local b := eng.CreateBox(cw/1.5,ch/4,cw/2,ch/2)
    b.SetColor(0,0,255)
    
  4. Add a text object that will display the text GAME OVER.
    Local tx1 := eng.CreateText(font1,"**** GAME OVER ****",cw/2,ch/2-30,3)
    
  5. To display the score, add another text object (txtFinalScore).
    txtFinalScore = eng.CreateText(font1,"SCORE: 000000",cw/2,ch/2+30,3)
    Return 0
    End
    

What just happened?

When this method is called later on, it will inform the player that the game has ended and show them the score they have attained.


  

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