animation.resume()

类型 函数
返回值
修订 版本 2024.3703
关键词 动画, 补间动画, 时间轴, 插值, 恢复
另请参阅 动画 — 补间动画和时间轴 (指南)
animation.pause()
补间动画
时间轴

概述

animation.resume() 函数根据传入的参数恢复以下内容:

重要

调用此方法以定位 时间轴 中的特定子补间动画将被忽略。时间轴补间动画由父时间轴控制/拥有,因此您应该通过此方法或 object:resume() 来恢复时间轴本身。

语法

animation.resume()
animation.resume( tweenObject )
animation.resume( displayObject )
animation.resume( tagName )
animation.resume( timelineObject )
tweenObject (可选)

补间动画. 要恢复的特定暂停 补间动画

displayObject (可选)

显示对象. 将在其上恢复所有暂停补间动画的显示对象。

tagName (可选)

字符串. 标签名称;所有带有此标签的暂停补间动画都将恢复。

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 } )

-- At some point, pause all tweens and timelines
animation.pause()

-- Sometime later, resume them
animation.resume()
特定补间动画
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 } )

-- At some point, pause a specific tween
animation.pause( tween1 )

-- Sometime later, resume it
animation.resume( 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 } )

-- At some point, pause all tweens on the object
animation.pause( object1 )

-- Sometime later, resume them
animation.resume( 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" } )

-- At some point, pause all tweens with the tag "tweenTag"
animation.pause( "tweenTag" )

-- Sometime later, resume them
animation.resume( "tweenTag" )