Let's add a touch event for the panda so that it flings toward the stars. The powerShot
object will play a role in helping the player visualize how much power needs to be applied to the panda, before it launches into the air.
Implement touch events for the panda. Create a local function called
onScreenTouch()
with an event parameter:local onScreenTouch = function( event )
With
gameIsActive
initiated, add in anif
statement for when the touch event starts, by usingevent.phase ==
"began"
. During this event, use the "crouch" animation set to preparepanda
for launch:if gameIsActive then if event.phase == "began" and panda.inAir == false then panda.y = 225 panda.isReady = true powerShot.isVisible = true powerShot.alpha = 0.75 powerShot.x = panda.x; powerShot.y = panda.y powerShot.xScale = 0.1; powerShot.yScale = 0.1 arrow.isVisible = true panda:setSequence("crouch") panda:play()
Add an
elseif
statement...