InteractionTrackerInertiaMotion 類別

定義

ExpressionAnimation,定義 InteractionTracker 在其慣性狀態期間動作。

InteractionTrackerMotion 類別包含兩個 ExpressionAnimation,代表 位置 InteractionTracker 的第二個衍生方程式,會在符合特定條件時,用來定義從慣性開始到結束的動作。 InteractionTrackerMotion 類別定義為兩個部分:要定義動作何時進行的條件陳述式,以及描述 InteractionTracker 如何到達其最終靜止位置的動作的方程式。 當您需要定義自訂動作 (時,請使用 InteractionTrackerInertiaMotion 類別,例如 Spring 動作) ,讓 InteractionTracker 在其慣性狀態下使用。

public ref class InteractionTrackerInertiaMotion sealed : InteractionTrackerInertiaModifier
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InteractionTrackerInertiaMotion final : InteractionTrackerInertiaModifier
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
class InteractionTrackerInertiaMotion final : InteractionTrackerInertiaModifier
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public sealed class InteractionTrackerInertiaMotion : InteractionTrackerInertiaModifier
Public NotInheritable Class InteractionTrackerInertiaMotion
Inherits InteractionTrackerInertiaModifier
繼承
Object Platform::Object IInspectable CompositionObject InteractionTrackerInertiaModifier InteractionTrackerInertiaMotion
屬性

範例

void CustomSpringInertiaMotion(float dampingCoefficient, 	float springStiffnessCoefficient)
{
  //
  // Set up our inertia modifiers to use our custom motion
  //
  InteractionTrackerInertiaMotion[] modifiers = 
  new InteractionTrackerInertiaMotion[1];

  var modifier1 = InteractionTrackerInertiaMotion.Create(_compositor);

  /*
  We create a custom spring motion for when the InteractionTracker passes the
  maximum boundary. 
  When we hit the boundary, the amount of oscillation is determined by the 	distance to the far end point, the spring stiffness and damping rate.
  */ 

  // Define the condition that the spring motion gets applied – when we pass the
  // maximum boundary
  modifier1.Condition = _compositor.CreateExpressionAnimation(
  "this.Target.NaturalRestingPosition.X > this.Target.MaxPosition.X");

  // Define the second derivative equation as a custom spring force motion
  // Equation = kx–cv where (k is spring constant, c is damping, x is displacement)
  modifier1.Motion = _compositor.CreateExpressionAnimation(
    "(-springStiffnessCoefficient * (this.Target.Position.X – this.Target.MaxPosition.X)) + " +
    "(-dampingCoefficient * target.PositionVelocityInPixelsPerSecond.X");

  modifier1.Motion.SetScalarParameter("springStiffnessCoefficient", springStiffnessCoefficient);
  modifier1.Motion.SetScalarParameter("dampingCoefficient", dampingCoefficient);

  modifiers[0] = modifier1;

  // Attach InertiaModifiers to the Y position component of InteractionTracker
  _tracker.ConfigurePositionYInertiaModifiers(modifiers);
}

備註

建置 InteractionTrackerInertiaMotion 動作元件的 ExpressionAnimation 時,運算式會描述為第二個衍生方程式。 例如,在上述程式碼片段中,我們會使用 Spring Force 動作的基本方程式,並具有阻流。

將 InteractionTrackerInertiaMotion 修飾詞附加至 InteractionTracker時,您可以將它設定為 X/Y 位置或小數位數。

定義條件屬性的 ExpressionAnimation 只有在 InteractionTracker 進入慣性 (,例如手指釋放) 等互動完成時,才會評估一次。 如果條件評估為 true,則慣性Motion 運算式會針對慣性其餘部分評估每個畫面格,即使條件運算式技術上不再為 True 亦然。

InteractionTrackerInertiaMotion 修飾詞會變更 InteractionTracker 用來計算其位置的方程式。 因此,最終的待用位置取決於方程式本身的本質。 如果您需要 InteractionTracker 在特定位置停止,請使用 InteractionTrackerInertiaRestingValue 修飾詞

屬性

Comment

要與 CompositionObject 建立關聯的字串。

(繼承來源 CompositionObject)
Compositor

用來建立這個CompositionObjectCompositor

(繼承來源 CompositionObject)
Condition

ExpressionAnimation,描述何時應套用修飾詞。

Condition 屬性是 ExpressionAnimation ,定義在慣性期間 由 InteractionTracker 使用指定的動作方程式時。 此運算式會在互動發生之後評估一次,而且必須解析為 Bool 類型,否則評估條件時會擲回錯誤。 如需建置運算式的詳細資訊,請參閱 ExpressionAnimation 類別頁面。

DispatcherQueue

取得 CompositionObject 的 DispatcherQueue。

(繼承來源 CompositionObject)
ImplicitAnimations

附加至這個物件的隱含動畫集合。

(繼承來源 CompositionObject)
Motion

如果 Condition 屬性中的運算式為 true,則描述InteractionTracker修改動作的ExpressionAnimation

Motion 屬性是 ExpressionAnimation ,描述項合對應條件時, 動作 InteractionTracker 會在慣性期間使用。 當 InteractionTracker 處於慣性且必須解析為 Float 類型時,運算式將會評估每個畫面格,否則評估方程式時會擲回錯誤。 如需建置運算式的詳細資訊,請參閱 ExpressionAnimation 類別頁面。

Properties

CompositionObject相關聯的屬性集合。

(繼承來源 CompositionObject)

方法

Close()

關閉 CompositionObject 並釋放系統資源。

(繼承來源 CompositionObject)
Create(Compositor)

建立 InteractionTrackerInertiaMotion的實例。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

(繼承來源 CompositionObject)
PopulatePropertyInfo(String, AnimationPropertyInfo)

定義可以產生動畫效果的屬性。

(繼承來源 CompositionObject)
StartAnimation(String, CompositionAnimation, AnimationController)

使用物件的指定屬性連接動畫,並啟動動畫。

(繼承來源 CompositionObject)
StartAnimation(String, CompositionAnimation)

使用物件的指定屬性連接動畫,並啟動動畫。

(繼承來源 CompositionObject)
StartAnimationGroup(ICompositionAnimationBase)

啟動動畫群組。

CompositionObject上的 StartAnimationGroup 方法可讓您啟動CompositionAnimationGroup。 群組中的所有動畫都會在 物件上同時啟動。

(繼承來源 CompositionObject)
StopAnimation(String)

中斷與指定屬性的動畫連線,並停止動畫。

(繼承來源 CompositionObject)
StopAnimationGroup(ICompositionAnimationBase)

停止動畫群組。

(繼承來源 CompositionObject)
TryGetAnimationController(String)

傳回在指定屬性上執行的動畫的 AnimationController。

(繼承來源 CompositionObject)

適用於

另請參閱