Last active
December 17, 2015 14:08
-
-
Save srdjan-m/5621775 to your computer and use it in GitHub Desktop.
corona: sprite listener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.