类型 函数 返回值 表格 修订版 2024.3703 版 关键字 动画、补间、时间轴、插值、getAnimations 另请参见 动画 — 补间和时间轴 (指南) 补间 时间轴
此函数必须通过显示对象引用或标记名称来调用。返回一个包含子 数组 tweens
和 timelines
的表,每个数组分别包含 Tween 和/或 Timeline 引用。
当使用显示对象引用调用时,这些数组将指示当前对显示对象有效的全部补间/时间轴。
当使用标记名称调用时,这些数组将指示共享相同标记名称的所有补间/时间轴。
animation.getAnimations( DisplayObjectOrTag )
DisplayObject 或 String。要获取全部 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