Skip to content

Instantly share code, notes, and snippets.

@srdjan-m
Last active December 17, 2015 14:08
Show Gist options
  • Save srdjan-m/5621775 to your computer and use it in GitHub Desktop.
Save srdjan-m/5621775 to your computer and use it in GitHub Desktop.
corona: sprite listener
local function mySpriteListener( event )
if ( event.phase == "ended" ) then
local thisSprite = event.target --"event.target" references the sprite
thisSprite:setSequence( "fastRun" ) --switch to "fastRun" sequence
thisSprite:play() --play the new sequence; it won't play automatically!
end
end
animation:addEventListener( "sprite", mySpriteListener ) --add a sprite listener to your sprite
@srdjan-m
Copy link
Author

Event phases:

began = The sprite has started playing.
ended = The sprite has finished playing.
bounce = The sprite has bounced from forward to backward while playing.
loop = The sprite has looped to the beginning of the sequence.
next = The sprite has played a subsequent frame that’s not one of the above phases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment