Reader small image

You're reading from  Corona SDK Mobile Game Development: Beginner's Guide

Product typeBook
Published inMar 2015
Publisher
ISBN-139781783559343
Edition1st Edition
Tools
Right arrow
Author (1)
Michelle M Fernandez
Michelle M Fernandez
Right arrow

Time for action – calling game over


We will make sure that when a game over display screen pops up, any of our display objects that are 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. To end the game, perform the following steps:

  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 the current background:

          shade = display.newRect( 0, 0, 570, 320 )
          shade:setFillColor( 0, 0, 0 )
          shade.x = 240; shade.y = 160
          shade.alpha = 0  -- Getting shade ready to display at game...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Corona SDK Mobile Game Development: Beginner's Guide
Published in: Mar 2015Publisher: ISBN-13: 9781783559343

Author (1)