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

7. Physics: Falling Objects > Time for action – calling game over

Time for action – calling game over

We are going to make sure that when a Game Over display screen pops up, any of our display objects currently in motion stop moving and the event listeners are deactivated. Aside from the visual display of our Game Over screen, we'll be adding a sound notification that will also help to trigger the event.

  1. Create a new local function called callGameOver() and place it after the setScore() function and before the drawBackground() function.
        local callGameOver = function()
  2. Introduce the sound effects when the Game Over display pops up. Have gameIsActive set to false and pause the physics in the game.
          audio.play( gameOverSound )
          gameIsActive = false
          physics.pause()
  3. Create a shade that overlays over the current background.
          shade = display.newRect( 0, 0, 570, 320 )
          shade:setFillColor( 0, 0, 0, 255 )
          shade.x = 240; shade.y = 160
          shade.alpha = 0

  

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