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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

7. Physics: Falling Objects > Time for action – activating the game

Time for action – activating the game

With all the gameplay elements set in place, it is time to get the application started.

  1. Create a new local function called gameActivate() and insert gameIsActive = true. Place the function above the moveChar() function.
        local gameActivate = function()
          gameIsActive = true
        end
  2. Initialize all the game actions by making a new function called gameStart().
        local gameStart = function()
  3. Start the physics property and set the gravity for the falling object.
          physics.start( true )
          physics.setGravity( 0, 9.8 )
  4. Activate all the functions instantiated. Add an event listener for the charObject using the "touch" for the moveChar() function.
          drawBackground()
          createChar()
          eggTimer()
          hud()
          gameActivate()
          Runtime:addEventListener("accelerometer", moveChar)
        end

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint