object:play()

Type Function
Object SpriteObject
Library display.*
Return value none
Revision Release 2024.3703
Keywords play
See also display.newSprite()
object:setSequence()
object:pause()

Overview

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

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:

See event.phase for more information.

Syntax

object:play()

Example

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 )