O'Reilly logo

Corona SDK Mobile Game Development by Michelle M. Fernandez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – pausing the game

It's more than just making a button, it's also pausing all the action onscreen, including physics and timers.

  1. Add in the variables local pauseBtn and local pauseBG where all the other variables are initialized near the beginning of the code. Preload the btnSound audio after gameOverSound near the top of the script.
    -- Place near other game variables
    local pauseBtn
    local pauseBG
    
    -- Place after gameOverSound
    local btnSound = audio.loadSound( "btnSound.wav" )
  2. Within thehud() function and after the scoreText chunk, create another function that will run the event for the pause button. Call the function onPauseTouch(event). Pause the physics in the game by setting gameIsActive to false and have the pause elements appear ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required