Empty
Empty
Empty
TweenService 是 Roblox 中的一個服務,允許您為 GUI 元素、部件和其他對象創建流暢的動畫。它用於在指定的持續時間內將對象的屬性從一個狀態插值到另一個狀態。
Tween | Tween 是一個動畫,它將對象的屬性從起始狀態插值到結束狀態。 |
TweenInfo | 這定義了 tween 的參數,例如持續時間、緩動樣式、緩動方向和重複。 |
緩動樣式和方向 | 緩動樣式定義了用於在 tween 的起始值和結束值之間插值的數學函數。緩動方向定義了 tween 如何相對於起始值和結束值進行。 |
可緩動對象
Empty
Empty
Empty
Position | 將部件/模型移動到新位置。 |
Size | 更改部件/模型的尺寸。 |
Orientation | 旋轉部件/模型。 |
Transparency | 調整部件/模型的透明度。 |
Color | 更改部件/模型的顏色。 |
Empty
Empty
Empty
Position | 將部件/模型移動到新位置。 |
Size | 更改部件/模型的尺寸。 |
BackgroundColor3 | 更改 GUI 元素的背景顏色。 |
Transparency | 調整部件/模型的透明度。 |
Empty
Empty
Empty
Brightness | 調整光源的亮度。 |
Color | 更改部件/模型的顏色。 |
Range | 更改光源的範圍。 |
Empty
Empty
Empty
CFrame | 移動或旋轉攝像機。 |
Empty
Empty
Empty
Volume | 調整聲音的音量。 |
PlaybackSpeed | 更改聲音的播放速度。 |
TweenService 示例
緩動位置
local TweenService = game:GetService("TweenService")
-- Define TweenInfo
local tweenInfo = TweenInfo.new(
2, -- Time (seconds)
Enum.EasingStyle.Quad, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat count (0 means no repeat)
false, -- Reverses (tween goes back and forth)
0 -- Delay time (seconds)
)
local part = script.Parent
part.Position = Vector3.new(0, 2.5, 0)
part.Anchored = true
part.Parent = workspace
-- Define the end state of the properties you want to tween
local goal = {}
goal.Position = Vector3.new(10, 5, 0)
-- Create the tween
local tween = TweenService:Create(part, tweenInfo, goal)
-- Play the tween
tween:Play()
Roblox Studio
緩動 GUI 元素
local TweenService = game:GetService("TweenService")
-- Define TweenInfo
local tweenInfo = TweenInfo.new(
2, -- Time (seconds)
Enum.EasingStyle.Quad, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat count (0 means no repeat)
false, -- Reverses (tween goes back and forth)
0 -- Delay time (seconds)
)
local part = script.Parent
part.Position = Vector3.new(0, 2.5, 0)
part.Anchored = true
part.Parent = workspace
-- Define the end state of the properties you want to tween
local goal = {}
goal.Position = Vector3.new(10, 5, 0)
-- Create the tween
local tween = TweenService:Create(part, tweenInfo, goal)
-- Play the tween
tween:Play()
Roblox Studio
緩動光源屬性
local TweenService = game:GetService("TweenService")
-- Define TweenInfo
local tweenInfo = TweenInfo.new(
2, -- Time (seconds)
Enum.EasingStyle.Quad, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat count (0 means no repeat)
false, -- Reverses (tween goes back and forth)
0 -- Delay time (seconds)
)
local part = script.Parent
part.Position = Vector3.new(0, 2.5, 0)
part.Anchored = true
part.Parent = workspace
-- Define the end state of the properties you want to tween
local goal = {}
goal.Position = Vector3.new(10, 5, 0)
-- Create the tween
local tween = TweenService:Create(part, tweenInfo, goal)
-- Play the tween
tween:Play()
Roblox Studio
緩動樣式
Empty
Empty
Empty
Linear | 從開始到結束以恆定速度移動。 |
Sine | 使用正弦波實現平滑、周期性的運動。 |
Back | 在到達終點前超出,然後回落到終點。 |
Quad | 快速加速,然後逐漸減速。 |
Cubic | 類似於 Quad,但具有更強的加速和減速效果。 |
Quart | 比 Cubic 更強的加速和減速效果。 |
Quint | 最強的加速和減速效果。 |
Bounce | 模仿結束時的彈跳效果。 |
Elastic | 以彈簧般的方式超出終點,然後回落。 |
Exponential | 起初緩慢,然後呈指數級加速。 |
Empty
Empty
Empty
In | 緩慢開始,在結束時加速。 |
Out | 快速開始,在結束時減速。 |
InOut | 結合了 'In' 和 'Out' 的特點,開始緩慢,中間加速,結束時再次減速。 |