Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
We need to set up the panda collision event and animate it with the sprite sheet accordingly.
createPanda().local createPanda = function()
onPandaCollision() with the parameters self and event. Reload panda every time a collision occurs with the stars or the edge of the screen by using callNewRound(). 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 panda.isHit then
return true
end
end
end