学习
引擎类
TweenService
无法创建
服务

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


概要
方法
Create(instance: Instance,tweenInfo: TweenInfo,propertyTable: Dictionary):Tween
GetValue(alpha: number,easingStyle: Enum.EasingStyle,easingDirection: Enum.EasingDirection):number
SmoothDamp(current: Variant,target: Variant,velocity: Variant,smoothTime: number,maxSpeed: number?,dt: number?):Tuple
继承成员
代码示例
动画创建
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()
循环 Tween
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace
local tweenInfo = TweenInfo.new(
2, -- 时间
Enum.EasingStyle.Linear, -- 缓动样式
Enum.EasingDirection.Out, -- 缓动方向
-1, -- 重复次数(当小于零时,tween 将无限循环)
true, -- 反转(tween 达到其目标后将反转)
0 -- 延迟时间
)
local tween = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 30, 0) })
tween:Play()
task.wait(10)
tween:Cancel() -- 在 10 秒后取消动画
暂停一个插值动画
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.BrickColor = BrickColor.new("Bright green")
part.Parent = workspace
local goal = {}
goal.Position = Vector3.new(50, 10, 0)
local tweenInfo = TweenInfo.new(10, Enum.EasingStyle.Linear)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(3)
part.BrickColor = BrickColor.new("Bright red")
tween:Pause()
task.wait(2)
part.BrickColor = BrickColor.new("Bright green")
tween:Play()

API 参考
方法
Create
功能: Basic
TweenService:Create(
instance:Instance, tweenInfo:TweenInfo, propertyTable:Dictionary
参数
instance:Instance
tweenInfo:TweenInfo
propertyTable:Dictionary
返回
代码示例
动画创建
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()
循环 Tween
local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace
local tweenInfo = TweenInfo.new(
2, -- 时间
Enum.EasingStyle.Linear, -- 缓动样式
Enum.EasingDirection.Out, -- 缓动方向
-1, -- 重复次数(当小于零时,tween 将无限循环)
true, -- 反转(tween 达到其目标后将反转)
0 -- 延迟时间
)
local tween = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 30, 0) })
tween:Play()
task.wait(10)
tween:Cancel() -- 在 10 秒后取消动画

GetValue
功能: Basic
TweenService:GetValue(
alpha:number, easingStyle:Enum.EasingStyle, easingDirection:Enum.EasingDirection
参数
alpha:number
easingStyle:Enum.EasingStyle
easingDirection:Enum.EasingDirection
返回

SmoothDamp
写入并联
功能: Basic
模拟访问权限
TweenService:SmoothDamp(
current:Variant, target:Variant, velocity:Variant, smoothTime:number, maxSpeed:number?, dt:number?
参数
current:Variant
target:Variant
velocity:Variant
smoothTime:number
maxSpeed:number?
dt:number?
返回

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。