Tween 개체는 인터폴레이션의 재생을 제어합니다.만들고 구성하는 Tween 는 TweenService:Create() 함수로 수행됩니다; Instance.new() 이 특정 개체에 사용할 수 없습니다.
십대가 생성된 후에 십대 구성에 액세스할 수는 있지만 수정할 수는 없습니다.인터폴레이션에 새로운 목표가 필요한 경우 새로운 Tween 가 생성되어야 합니다.
또한 여러 십대가 동시에 동일한 개체에서 재생될 수 있지만 동일한 속성을 인터폴레이션해서는 안됩니다.두 청소년이 동일한 속성을 수정하려고 시도하면 초기 청소년이 취소되고 가장 최근의 청소년에 의해 덮어쓰입니다.
코드 샘플
In this example a Tween is created to animate the position and color of a Part. Because the position and color are part of the same tween, they will change at the exact same rate and will reach their goal at the same time.
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()
요약
메서드
메서드가 TweenBase에서 상속되었습니다재생을 중지하고 청소년 변수를 재설정합니다.그런 다음 TweenBase:Play()를 호출하면 청소년의 목적지로 이동하는 속성이 재개되지만, 그렇게 하기 위해 애니메이션의 전체 길이를 사용합니다.
청소년의 재생을 중지합니다.진행률 변수를 재설정하지 않으므로, TweenBase:Play()를 호출하면 청소년의 재생이 일시 중지된 순간부터 재개됩니다.
청소년의 재생을 시작합니다.재생이 이미 시작되었으면 Play()를 호출하더라도 청소년이 완료되거나 중지되지 않으면 효과가 없습니다(TweenBase:Cancel() 또는 TweenBase:Pause()에 의해).
속성
Instance
이 속성의 Tween (읽기 전용) 포인트는 속성이 인터폴레이션되는 Instance 의 지점을 가리킵니다.
코드 샘플
This code sample includes a simple function that will return true if the instance of a tween is a Part.
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
Tween 의 인터폴레이션 방법에 대한 정보를 포함하는 읽기 전용 속성, TweenInfo 데이터 입력사용하여.
코드 샘플
An example of the range of different interpolation effects that can be used in Tweens.
-- A TweenInfo with all default parameters
TweenInfo.new()
-- A TweenInfo with its time set to 0.5 seconds.
TweenInfo.new(0.5)
-- A TweenInfo with its easing style set to Back.
TweenInfo.new(0.5, Enum.EasingStyle.Back)
-- A TweenInfo with its easing direction set to In.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In)
-- A TweenInfo that repeats itself 4 times.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4)
-- A TweenInfo that reverses its interpolation after reaching its goal.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4, true)
-- A TweenInfo that loops indefinitely.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, -1, true)
-- A TweenInfo with a delay of 1 second between each interpolation.
TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.In, 4, true, 1)