animation.getAnimations()

类型 函数
返回值 表格
修订版 2024.3703 版
关键字 动画、补间、时间轴、插值、getAnimations
另请参见 动画 — 补间和时间轴 (指南)
补间
时间轴

概览

此函数必须通过显示对象引用或标记名称来调用。返回一个包含子 数组 tweenstimelines 的表,每个数组分别包含 Tween 和/或 Timeline 引用。

当使用显示对象引用调用时,这些数组将指示当前对显示对象有效的全部补间/时间轴。

当使用标记名称调用时,这些数组将指示共享相同标记名称的所有补间/时间轴。

语法

animation.getAnimations( DisplayObjectOrTag )
显示对象或标记 (必需)

DisplayObjectString要获取全部 Tween 和/或 Timeline 引用的显示对象或标记名称。

示例

显示对象
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
标记插值
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