object:getPosition()

Type Function
Return value Number
Revision Release 2024.3703
Keywords animation, tween, interpolation, getPosition
See also object:setPosition()
animation.setPosition()
Tween
animation.*

Overview

The object:getPosition() method returns the position of the Tween in milliseconds.

Notes

This value may be greater than the duration of the tween, essentially indicating that it has completed. If necessary, the returned value can be constrained to a range between 0 and the tween's duration by passing true to the method call — see below for details.

Syntax

object:getPosition( [getClipped] )
getClipped (optional)

Boolean. If true, the returned value will be between 0 and the tween's duration. Default is false.

Example

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

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

-- Sometime later, pause the tween
newTween:pause()

-- Check the tween position
local currentPosition = newTween:getPosition()
print( currentPosition )