animation.from()

Type Function
Return value Tween
Revision Release 2024.3703
Keywords animation, tween, timeline, interpolation, from
See also Animation — Tweens and Timelines (guide)
animation.to()
Tween
Timeline

Overview

Similar to animation.to() except that the starting property values are specified in the properties table and the final values are the corresponding property values of the object prior to the call.

Syntax

animation.from( target, properties, params )
target (required)

DisplayObject or Userdata. The display object, RectPath point, Paint fill, or fill.effect to tween.

properties (required)

Table. A table that specifies the properties of the object that will be interpolated — see animation.to() for a list of common options.

params (required)

Table. A table which specifies control parameters for the tween — see animation.to() for parameter references.

Example

Basic Movement
local square = display.newRect( 0, 0, 100, 100 )

local w, h = display.contentWidth, display.contentHeight

local function tweenListener( obj )
    print( "Tween completed; ID: " .. obj.id )
end

-- Move square from bottom right corner to upper left corner
animation.from( square, { x=(w-50), y=(h-50) }, { time=1500, id="tween1", onComplete=tweenListener } )