For many of the functions we have created for our game objects we need to activate the event listeners so that they will run the code and disable them when gameplay has stopped.
The last function we need to create in order to complete this game is called
gameListeners()
, which will also have a parameter calledevent
. This should be added right after thegameLevel2()
function.function gameListeners(event)
Add in the following event listeners that will start several events in the application using an
if
statement:if event == "add" then Runtime:addEventListener("accelerometer", movePaddle) Runtime:addEventListener("enterFrame", updateBall) paddle:addEventListener("collision", bounce) ball:addEventListener("collision", removeBrick) paddle:addEventListener("touch", dragPaddle)
Next we'll add in an
elseif
statement for the event listeners that will remove the events and then close the function.elseif event == "remove" then Runtime...