Tween
Overview
Tween is used to smoothly and naturally change the properties of an object. By using Tween, various properties such as the object’s position, rotation, and size can be animated, adding immersive and rich visual effects to the game.
Features
Tweens excel in both code simplicity and performance, helping to easily implement various effects.
Tweens support various Easing styles, providing smooth and natural animations.
Tweens are processed internally in an efficient manner, and their performance overhead is lower compared to frame-by-frame updates.
Tweens automatically terminate once completed, and subsequent tasks can be easily handled in the Completed event.
Components
TweenService: The service used to create and manage tweens.
TweenInfo: An object that defines how the tween behaves, including settings for duration, direction, and repeat count.
TweenGoals: Defines the property values to be changed by the tween.
How to Use
1. Creating a Tween
You can define the behavior of a tween animation, such as its duration, easing style, and repeat count, using the TweenInfo.new function.
The properties to which the animation will be applied, such as the object’s position or rotation, are set in the TweenGoals table.
2. Setting Properties to Be Changed With the Tween
The functionality of the tween varies depending on the properties set in the TweenGoals.
3. Running the Tween
You can create a tween by passing the target object, the pre-configured TweenInfo, and TweenGoals to the TweenService:Create function. Once the tween is created, it can be executed using the Play function.
4. Controlling the Tween Execution
A tween that is running can be paused using the Pause function.
The Cancel function can be used to cancel a running tween.
5. Handling Events After the Tween Ends
The Completed event can be used to handle actions after a tween finishes executing.
Last updated