object:getSpeedScale()

Type Function
Return value Number
Revision Release 2024.3703
Keywords animation, timeline, interpolation, getSpeedScale
See also object:setSpeedScale()
animation.setSpeedScale()
Timeline
animation.*

Overview

The object:getSpeedScale() method returns the speed scale of the Timeline as set via object:setSpeedScale() or animation.setSpeedScale().

Syntax

object:getSpeedScale()

Example

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 speed scale
newTimeline:setSpeedScale( 2.5 )

-- Set the timeline playing
newTimeline:resume()

-- Get the speed scale
local currentSpeedScale = newTimeline:getSpeedScale()
print( currentSpeedScale )  --> 2.5