TweenBase

사용되지 않는 항목 표시

*이 콘텐츠는 AI(베타)를 사용해 번역되었으며, 오류가 있을 수 있습니다. 이 페이지를 영어로 보려면 여기를 클릭하세요.

만들 수 없음
찾아볼 수 없음

중간 인터폴레이션 처리기의 추상 기본 클래스; Tween의 부모 클래스.

요약

속성

메서드

  • Cancel():()

    재생을 중지하고 청소년 변수를 재설정합니다.그런 다음 TweenBase:Play()를 호출하면 청소년의 목적지로 이동하는 속성이 재개되지만, 그렇게 하기 위해 애니메이션의 전체 길이를 사용합니다.

  • Pause():()

    청소년의 재생을 중지합니다.진행률 변수를 재설정하지 않으므로, TweenBase:Play()를 호출하면 청소년의 재생이 일시 중지된 순간부터 재개됩니다.

  • Play():()

    청소년의 재생을 시작합니다.재생이 이미 시작되었으면 Play()를 호출하더라도 청소년이 완료되거나 중지되지 않으면 효과가 없습니다(TweenBase:Cancel() 또는 TweenBase:Pause()에 의해).

이벤트

속성

PlaybackState

읽기 전용
복제되지 않음
병렬 읽기

Tween 애니메이션의 현재 단계를 보여주는 읽기 전용 속성.각 상태의 설명은 Enum.PlaybackState에 참조하십시오.Tween:Play()와 같은 함수를 사용하여 변경.

코드 샘플

Tween PlaybackState

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace
local goal = {}
goal.Orientation = Vector3.new(0, 90, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 2, true, 0.5)
local tween = TweenService:Create(part, tweenInfo, goal)
local function onPlaybackChanged()
print("Tween status has changed to:", tween.PlaybackState)
end
local playbackChanged = tween:GetPropertyChangedSignal("PlaybackState")
playbackChanged:Connect(onPlaybackChanged)
tween:Play()

메서드

Cancel

()

Tween의 재생을 중지하고 청소년 변수를 재설정합니다.

오직 십대 변수만 재설정하고, 십대에 의해 변경되는 속성은 그대로 유지됩니다.애니메이션 중간에 미성년자를 취소하면 속성이 원래 값으로 재설정되지 않습니다.일단 재시작되면 완전한 시간이 걸려서 애니메이션이 완료되는 점이 TweenBase:Pause()와 다릅니다.


반환

()

코드 샘플

청소년 취소

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace
local goal = {}
goal.Position = Vector3.new(0, 50, 0)
local tweenInfo = TweenInfo.new(5)
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
task.wait(2.5)
tween:Cancel()
local playTick = tick()
tween:Play()
tween.Completed:Wait()
local timeTaken = tick() - playTick
print("Tween took " .. tostring(timeTaken) .. " secs to complete")
-- The tween will take 5 seconds to complete as the tween variables have been reset by tween:Cancel()

Pause

()

청소년의 재생을 중지합니다.진행률 변수를 재설정하지 않으므로, TweenBase:Play()를 호출하면 청소년의 재생이 일시 중지된 순간부터 재개됩니다.

tween의 진행률 변수를 재설정하려면 TweenBase:Cancel()를 사용하십시오.

오직 PlaybackStateEnum. PlaybackState.Playing 에 있는 십대만 일시 중지할 수 있습니다; 다른 상태의 십대는 일시 중지하지 않습니다.만약 청소년이 0보다 크다는 이유로 다른 (예: )에 있다면, 일시 중지를 시도하면 실패하고 청소년은 지정된 지연 시간 후에 재생됩니다.


반환

()

코드 샘플

Pausing a Tween

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()

Play

()

청소년의 재생을 시작합니다.재생이 이미 시작되었으면 Play()를 호출하더라도 청소년이 완료되거나 중지되지 않으면 효과가 없습니다(TweenBase:Cancel() 또는 TweenBase:Pause()에 의해).

여러 십대가 동시에 같은 개체에서 재생할 수 있지만, 동일한 속성을 애니메이션하면 안됩니다.두 청소년이 동일한 속성을 수정하려고 시도하면 초기 청소년이 취소되고 최신 청소년에 의해 덮어씁니다(예제 참조).


반환

()

코드 샘플

Tween Creation

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 Conflict

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = game.Workspace
local tweenInfo = TweenInfo.new(5)
-- create two conflicting tweens (both trying to animate part.Position)
local tween1 = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 10, 20) })
local tween2 = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 30, 0) })
-- listen for their completion status
tween1.Completed:Connect(function(playbackState)
print("tween1: " .. tostring(playbackState))
end)
tween2.Completed:Connect(function(playbackState)
print("tween2: " .. tostring(playbackState))
end)
-- try to play them both
tween1:Play()
tween2:Play()

이벤트

Completed

청소년 핀이 재생을 마칠 때 또는 TweenBase:Cancel()로 중지될 때 발생합니다.

트위언이 종료된 이유에 대한 지표를 제공하기 위해 연결된 모든 함수에 트위언의 Enum.PlaybackState를 전달합니다.호출 TweenBase:Pause() 는 이벤트 Completed 를 발생시키지 않습니다.

매개 변수

playbackState: Enum.PlaybackState

완료 시의 청소년의 Enum.PlaybackState입니다.


코드 샘플

Tween Completed

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local SLOW_DURATION = 10
local function slowCharacter(humanoid)
local goal = {}
goal.WalkSpeed = 0
local tweenInfo = TweenInfo.new(SLOW_DURATION)
local tweenSpeed = TweenService:Create(humanoid, tweenInfo, goal)
tweenSpeed:Play()
return tweenSpeed
end
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local initialSpeed = humanoid.WalkSpeed
local tweenSpeed = slowCharacter(humanoid)
tweenSpeed.Completed:Wait()
humanoid.WalkSpeed = initialSpeed
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Tween Conflict

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = game.Workspace
local tweenInfo = TweenInfo.new(5)
-- create two conflicting tweens (both trying to animate part.Position)
local tween1 = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 10, 20) })
local tween2 = TweenService:Create(part, tweenInfo, { Position = Vector3.new(0, 30, 0) })
-- listen for their completion status
tween1.Completed:Connect(function(playbackState)
print("tween1: " .. tostring(playbackState))
end)
tween2.Completed:Connect(function(playbackState)
print("tween2: " .. tostring(playbackState))
end)
-- try to play them both
tween1:Play()
tween2:Play()
Verifying a Tween has Completed

local TweenService = game:GetService("TweenService")
local part = Instance.new("Part")
part.Position = Vector3.new(0, 50, 0)
part.Anchored = true
part.Parent = workspace
local goal = {}
goal.Position = Vector3.new(0, 0, 0)
local tweenInfo = TweenInfo.new(3)
local tween = TweenService:Create(part, tweenInfo, goal)
local function onTweenCompleted(playbackState)
if playbackState == Enum.PlaybackState.Completed then
local explosion = Instance.new("Explosion")
explosion.Position = part.Position
explosion.Parent = workspace
part:Destroy()
task.delay(2, function()
if explosion then
explosion:Destroy()
end
end)
end
end
tween.Completed:Connect(onTweenCompleted)
tween:Play()