Tween

非推奨を表示

*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。

Tween オブジェクトは、インターポレーションの再生を制御します。作成および構成の TweenTweenService:Create() 関数で行われ、この特定のオブジェクトには Instance.new() 使用できません。

注:ティーンの設定は、ティーンが作成された後にアクセスできますが、修正することはできません。インターポレーションに新しい目標が必要な場合、新しい Tween が作成されなければなりません。

また、複数のティーンが同時に同じオブジェクトで再生できることに注意してくださいが、同じプロパティをインターポレートしてはなりません。2人のティーンが同じプロパティを変更しようとすると、最初のティーンがキャンセルされ、最新のティーンに上書きされます。

コードサンプル

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.

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 によってインターポレートされる Instance のプロパティを指す読み取り専用プロパティ。

  • 読み取り専用
    複製されていません
    並列読み取り

    Tween のインターポレーション方法に関する情報を含む読み込み専用プロパティ。

TweenBase から継承した プロパティ
  • 読み取り専用
    複製されていません
    並列読み取り

    Tween アニメーションの現在の状態を表示する読み取り専用プロパティ。

方法

TweenBase から継承した 方法
  • Cancel():()

    再生を停止し、tween 変数をリセットします。その後、TweenBase:Play() を呼び出すと、ティーンのプロパティが目的地にインターポレートしますが、そのためにはアニメーションの全長を取ります。

  • Pause():()

    tween の再生を停止します。進行変数をリセットしないため、TweenBase:Play() を呼択すると、ティーンは一時停止した瞬間から再生を再開します。

  • Play():()

    tween の再生を開始します。再生がすでに開始されている場合、Play() を呼び出すと、tweenが終了したか停止した場合を除き、効果はありません(TweenBase:Cancel() または TweenBase:Pause() によって)。

イベント

TweenBase から継承した イベント

プロパティ

Instance

読み取り専用
複製されていません
並列読み取り

このプロパティの Tween (読み込み専用) は、プロパティがインターポレートされている Instance のポイントを指します。

コードサンプル

This code sample includes a simple function that will return true if the instance of a tween is a Part.

Tween Instance

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.

TweenInfo Examples

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

方法

イベント