Tween

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

Tween 对插值件的播放进行控制。创建和配置插件的 Tween 使用 TweenService:Create() 函数; 1>Datatype.Instance.new1> 不能用于此特定对象。

注意:在 tween 创建后,可以访问 tween 的配置,但不能修改。如果需要对 interpolation 进行新的插值标,必须创建一个新的 Tween

请注意,多个叮唤者可以同时在同一对象上玩,但他们不能相互侵权。如果两个叮唤者尝试修改同一属性,初始叮唤将被取消并由最新叮唤覆盖。如果两个叮唤者尝试修改相同的属性,初始叮唤将被取消并覆盖最新补间动画。

代码示例

In this example a Tween is created to animate the position and color of a Part. Because the position and color are part of the same tween, they will change at the exact same rate and will reach their goal at the same time.

Tween Creation

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Color = Color3.new(1, 0, 0)
part.Anchored = true
part.Parent = game.Workspace
local goal = {}
goal.Position = Vector3.new(10, 10, 0)
goal.Color = Color3.new(0, 1, 0)
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()

概要

属性

继承自TweenBase属性

方法

继承自TweenBase方法
  • Cancel():void

    停止播放,然后重置 tween 变量。如果你 then call TweenBase:Play() , tween 变量的属性将继续交叉到目的地,但需要完整长度的动画才能完成。

  • Pause():void

    停止播放 тви补间动画。不会重置其进度变量,因此如果您调用 TweenBase:Play(),斑点将从暂停的那一刻起重新播放。

  • Play():void

    开始播放一个补间动画。如果播放已经开始,调用 Play() 无效,除非特效已经完成或已停止(通过 TweenBase:Cancel()TweenBase:Pause() 来)。

活动

继承自TweenBase活动

属性

Instance

只读
未复制
读取并联

Tween 的 Tween 属性 (只读) 指向其它 Instance 的属性正在被实现。

代码示例

This code sample includes a simple function that will return true if the instance of a tween is a Part.

Tween Instance

local TweenService = game:GetService("TweenService")
local function isInstanceAPart(tween)
local instance = tween.Instance
return instance:IsA("BasePart")
end
local tweenInfo = TweenInfo.new()
local instance = Instance.new("Part")
local tween = TweenService:Create(instance, tweenInfo, {
Transparency = 1,
})
print(isInstanceAPart(tween))

TweenInfo

只读
未复制
读取并联

只读性属性,包含用于使用 Tween 的插输入进行交换的方法的信息。

代码示例

An example of the range of different interpolation effects that can be used in Tweens.

TweenInfo Examples

-- A TweenInfo with all default parameters
TweenInfo.new()
-- A TweenInfo with its time set to 0.5 seconds.
TweenInfo.new(0.5)
-- A TweenInfo with its easing style set to Back.
TweenInfo.new(0.5, Enum.EasingStyle.Back)
-- A TweenInfo with its easing direction set to In.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In)
-- A TweenInfo that repeats itself 4 times.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4)
-- A TweenInfo that reverses its interpolation after reaching its goal.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4, true)
-- A TweenInfo that loops indefinitely.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, -1, true)
-- A TweenInfo with a delay of 1 second between each interpolation.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4, true, 1)

方法

活动