animation.getAnimations()

Type Function
Return value Table
Revision Release 2024.3703
Keywords animation, tween, timeline, interpolation, getAnimations
See also Animation — Tweens and Timelines (guide)
Tween
Timeline

Overview

This function must be called with a display object reference or tag name. Returns a table containing child arrays tweens and timelines, each of which contains Tween and/or Timeline references respectively.

When called with a display object reference, these arrays will indicate all tweens/timelines currently in effect for the display object.

When called with a tag name, these arrays will indicate all tweens/timelines which share that same tag name.

Syntax

animation.getAnimations( DisplayObjectOrTag )
DisplayObjectOrTag (required)

DisplayObject or String. The display object or tag name for which to fetch all Tween and/or Timeline references.

Examples

Display Object
local object = display.newRect( 50, 50, 100, 100 )

-- Run three tweens on the object
local tween1 = animation.to( object, { x=300 }, { time=4000 } )
local tween2 = animation.to( object, { y=400 }, { time=2000 } )
local tween3 = animation.to( object, { alpha=0.5 }, { time=500, delay=3500 } )

-- Get the tween references
local interpolations = animation.getAnimations( object )
for i = 1,#interpolations.tweens do
    print( interpolations.tweens[i] )
end
Tagged Interpolations
local object1 = display.newRect( 50, 50, 100, 100 )
local object2 = display.newRect( 50, 150, 100, 100 )

-- Run two tweens sharing the tag "tweenTag"
local tween1 = animation.to( object1, { y=300 }, { time=4000, tag="tweenTag" } )
local tween2 = animation.to( object2, { y=400 }, { time=2000, tag="tweenTag" } )

-- Get the tween references
local interpolations = animation.getAnimations( "tweenTag" )
for i = 1,#interpolations.tweens do
    print( interpolations.tweens[i] )
end