animation.from()

类型 函数
返回值 补间
修订版 发布 2024.3703
关键词 动画、补间、时间轴、插值、from
另请参见 动画 — 补间和时间轴 (指南)
animation.to()
补间
时间轴

概述

animation.to() 类似,只是起始属性值在 properties 表中指定,并且最终值是调用之前对象的对应属性值。

语法

animation.from( target, properties, params )
target (必需)

DisplayObjectUserdata要进行补间的显示对象、RectPath 点、Paint 填充或 fill.effect

properties (必需)

Table一个指定将进行插值的对象属性的表 - 请参阅 animation.to() 以获取常见选项列表。

params (必需)

Table一个指定补间控件参数的表 - 请参阅 animation.to() 以获取参数参考。

示例

基本运动
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 } )