类型 函数 返回值 无 修订 版本 2024.3703 关键词 动画, 补间动画, 时间轴, 插值, 取消 另请参阅 动画 — 补间动画和时间轴 (指南) 补间动画 时间轴
animation.cancel()
函数将根据传入的参数取消以下内容:
调用此方法以定位 时间轴 中的特定子补间动画将被忽略。时间轴补间动画由父时间轴控制/拥有,因此您应该通过此方法或 object:cancel() 取消时间轴本身。
animation.cancel() animation.cancel( tweenObject ) animation.cancel( displayObject ) animation.cancel( tagName ) animation.cancel( timelineObject )
显示对象. 将取消其上所有关联补间动画的显示对象。
字符串. 标签名称;所有带有此标签的补间动画都将被取消。
local object1 = display.newRect( 50, 50, 100, 100 ) local object2 = display.newRect( 50, 150, 100, 100 ) local tween1 = animation.to( object1, { y=300 }, { time=400 } ) local tween2 = animation.to( object2, { y=400 }, { time=200 } ) -- Sometime later, cancel all tweens and timelines animation.cancel()
local object1 = display.newRect( 50, 50, 100, 100 ) local object2 = display.newRect( 50, 150, 100, 100 ) local tween1 = animation.to( object1, { y=300 }, { time=400 } ) local tween2 = animation.to( object2, { y=400 }, { time=200 } ) -- Sometime later, cancel a specific tween animation.cancel( tween1 )
local object1 = display.newRect( 50, 50, 100, 100 ) local tween1 = animation.to( object1, { y=300 }, { time=2000 } ) local tween2 = animation.to( object1, { rotation=90 }, { time=1000, delay=1000 } ) -- Sometime later, cancel all tweens on the object animation.cancel( object1 )
local object1 = display.newRect( 50, 50, 100, 100 ) local object2 = display.newRect( 50, 150, 100, 100 ) local tween1 = animation.to( object1, { y=300 }, { time=400, tag="tweenTag" } ) local tween2 = animation.to( object2, { y=400 }, { time=200, tag="tweenTag" } ) -- Sometime later, cancel all tweens with the tag "tweenTag" animation.cancel( "tweenTag" )