Let's add a touch event for the panda so that it flings towards the stars. The powerShot
object will play a role by helping the player visualize how much power is 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 prepare panda 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:prepare("crouch") panda:play()
Add an
elseif...