Tween||doc136781

September 20, 2022

Tween

Brief Introduction

In the development process of the game, we will use a lot of displacement, rotation and scaling gradient animation, such as the response of buttons, the movement of 3D objects, moving by path, or color gradient, etc. This kind of animation is called tween animation.

The data types that support tween are:
· number
· Vector3
· Vector2
· Color3
· string
· bool

Constructor

Tween Tween.newInstance instance, TweenInfo tweenInfo, table<string, variant> properties )
Create a tween instance

Attribute

Instance Instance [ReadOnly]
Example of jogging animation
TweenPlayStatus PlayStatus [ReadOnly]
The playback status of the current jog animation
float TimeScale
Time scaling of jog animation

Function

void Play()
Play jog animation
void Cancel()
Cancel jog animation
void Pause()
Pause jog animation
BindableEvent GetEventstring eventName )
Get jog events

event

BindableEvent OnCompleted
Animation playback end event

Code example

Create a jog information instance, change the information and view the animation effect

-- Create an instance of easing information with all default values
local tweenInfo = TweenInfo.new()

-- Create an easing animation instance and play it, ins is the instance object for animation, modify the size property of the instance
local tween = Tween.new(ins, tweenInfo, {scale = 2})
tween:Play()

-- Print information when animation playback ends
local completeEvent = tween:GetEvent("OnCompleted")
completeEvent:Bind(function()
     print("tween complete!!!")
end)