Type Function Object SpriteObject Library display.* Return value none Revision Release 2024.3703 Keywords play See also display.newSprite() object:setSequence() object:pause()
Play an animation sequence, starting at the current frame. This does not reset looping.
Note that object:setSequence() must be called before the sequence can be played. Play can also be called after object:pause().
Sprite events are dispatched to the object’s listener. These events tell what phase of the animation playback the sprite is in. These can have one of the following phases:
"began"
the sprite began playing"ended"
the sprite finished playing"bounce"
the sprite bounces from forward to backward while playing"loop"
the sprite loops from the beginning of the sequence"next"
the sprite plays a subsequent frame that’s none of the above phasesSee event.phase for more information.
object:play()
spriteObj:setSequence( "man" ) spriteObj:play() -- add the event listener to the sprite object local function spriteListener( event ) print( "Sprite event: " .. event.phase ) end -- Add sprite listener spriteObj:addEventListener( "sprite", spriteListener )