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 – initializing the game


The physics and the remaining game functions need to be initialized to run the game. All game actions need to be delayed until the help screen has left the stage.

  1. Start the game by creating a new function called gameInit(), which will hold the physics properties and activate the display objects on the stage:

    local gameInit = function()
      physics.start( true )
      physics.setGravity( 0, 9.8 )
    
      drawBackground()
      createPowerShot()
      createPanda()
      createStars()
      hud()
  2. Add in a Runtime event listener, using "touch" for onScreenTouch():

      Runtime:addEventListener( "touch", onScreenTouch )
  3. Have the level and timer start 10 seconds later so that the user has time to read through the help text. Close the function and start the game with gameInit():

      local roundTimer = timer.performWithDelay( 10000, function() startNewRound(); end, 1 )
      local gameTimer = timer.performWithDelay( 10000, function() startTimer(); end, 1 )
    end
    
    gameInit()

All the code is completed...

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)