With all the gameplay elements set in place, it is time to get the application started.
Create a new local function called
gameActivate()
and insertgameIsActive = true
. Place the function above themoveChar()
function.local gameActivate = function() gameIsActive = true end
Initialize all the game actions by making a new function called
gameStart()
.local gameStart = function()
Start the physics property and set the gravity for the falling object.
physics.start( true ) physics.setGravity( 0, 9.8 )
Activate all the functions instantiated. Add an event listener for the
charObject
using the"touch"
for themoveChar()
function.drawBackground() createChar() eggTimer() hud() gameActivate() Runtime:addEventListener("accelerometer", moveChar) end
Instantiate the
gameStart()
function and return the groupgameGroup
.gameStart() return gameGroup