object:getDuration()

Type Function
Return value Number
Revision Release 2024.3703
Keywords animation, tween, interpolation, getDuration
See also Tween
animation.*

Overview

The object:getDuration() method returns the duration of the Tween in milliseconds.

Notes
  • This value will be affected by the tween’s speed scale.

  • In the instance of an endless tween (infinite iterations), this value will be nil because there is effectively no pre-determined duration.

Syntax

object:getDuration()

Example

local object1 = display.newRect( 50, 50, 100, 100 )

-- Move the object
local newTween = animation.to( object1, { x=150, y=400 }, { time=5000, delay=1000 } )

-- Get the animation's playing duration
local duration = newTween:getDuration()
print( duration )  --> 5000