Lớp công cụ
Tween
*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.
Tóm Tắt
Mẫu mã
Tạo Tween
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()Tài Liệu Tham Khảo API
Thuộc Tính
Instance
Mẫu mã
Thế hệ Tween
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
Mẫu mã
Ví dụ TweenInfo
-- Một TweenInfo với tất cả các tham số mặc định
TweenInfo.new()
-- Một TweenInfo với thời gian được đặt là 0.5 giây.
TweenInfo.new(0.5)
-- Một TweenInfo với kiểu easing được đặt thành Back.
TweenInfo.new(0.5, Enum.EasingStyle.Back)
-- Một TweenInfo với hướng easing được đặt thành In.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In)
-- Một TweenInfo lặp lại 4 lần.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4)
-- Một TweenInfo đảo ngược nội suy của nó sau khi đạt được mục tiêu.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4, true)
-- Một TweenInfo lặp vô hạn.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, -1, true)
-- Một TweenInfo có độ trễ 1 giây giữa mỗi nội suy.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4, true, 1)