We need to set up the panda collision event and animate it with the sprite sheet accordingly.
We need to create a local function that will introduce the collision and touch events for the panda. We shall call it
createPanda()
.local createPanda = function()
When the panda collides with the stars, use
onPandaCollision()
with the parametersself
andevent
. Reloadpanda
every time a collision occurs with the stars or the edge of the screen by usingcallNewRound()
.local onPandaCollision = function( self, event ) if event.phase == "began" then if panda.isHit == false then panda.isHit = true if event.other.myName == "star" then callNewRound( true, "yes" ) else callNewRound( true, "no" ) end if event.other.myName == "wall" then callNewRound( true, "yes" ) else callNewRound( true, "no" ) end elseif...