Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By : Michelle M Fernandez
Book Image

Corona SDK Mobile Game Development: Beginner's Guide

By: Michelle M Fernandez

Overview of this book

Table of Contents (19 chapters)
Corona SDK Mobile Game Development Beginner's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – displaying the game over screen


We need to set up the game over screen and have it display the final score that the player has achieved at the end of the round:

  1. Create a new local function called callGameOver():

    local callGameOver = function()
  2. Set gameIsActive as false and pause the physics engine. Remove the panda and stars objects from the stage:

      gameIsActive = false
      physics.pause()
    
      panda:removeSelf()
      panda = nil
      stars:removeSelf()
      stars = nil
  3. Display the game over objects and insert them into the hudGroup group. Use the transition.to method to display the game over objects on the screen:

      local shade = display.newRect( 0, 0, 480, 320 )
      shade:setFillColor( 0, 0, 0, 0.5)
      shade.x = display.contentCenterX
      shade.y = display.contentCenterY
    
      gameOverDisplay = display.newImage( "gameOverScreen.png")
      gameOverDisplay.x = 240; gameOverDisplay.y = 160
      gameOverDisplay.alpha = 0
    
      hudGroup:insert( shade )
      hudGroup:insert( gameOverDisplay )
    
      transition.to(...