Type Function Return value none Revision Release 2025.3721 Keywords animation, timeline, interpolation, setPosition See also object:getPosition() animation.setPosition() Timeline animation.*
Moves/sets the playback position of a Timeline created with animation.newTimeline().
object:setPosition( position )
Number or String. The position (time or marker) to move/set the playback to, as follows:
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()