类型 函数 返回值 无 修订 版本 2024.3703 关键词 动画, 时间轴, 插值, setPosition 另请参阅 object:getPosition() animation.setPosition() 时间轴 animation.*
移动/设置使用 animation.newTimeline() 创建的 时间轴 的播放位置。
object:setPosition( position )
local object1 = display.newRect( 50, 50, 100, 100 )
-- Create a timeline object
local timelineParams = {
tweens = {
{ startTime=0, tween={ object1, { x=400 }, { time=4000, iterations=5 } } },
{ startTime=1000, tween={ object1, { y=400 }, { time=4000, easing=easing.outQuad } } }
}
}
local newTimeline = animation.newTimeline( timelineParams )
-- Set the timeline position
newTimeline:setPosition( 2000 )
-- Set the timeline playing
newTimeline:resume()
local object1 = display.newRect( 50, 50, 100, 100 )
-- Create a timeline object
local timelineParams = {
tweens = {
{ startTime=0, tween={ object1, { x=400 }, { time=4000, iterations=5 } } },
{ startTime=1000, tween={ object1, { y=400 }, { time=4000, easing=easing.outQuad } } }
},
markers = {
{ name="marker_start", time=0 },
{ name="marker_2000", time=2000 },
{ name="marker_3000", time=3000 }
}
}
local newTimeline = animation.newTimeline( timelineParams )
-- Set the timeline position
newTimeline:setPosition( "marker_2000" )
-- Set the timeline playing
newTimeline:resume()