InteractionTracker.TryUpdatePositionWithAnimation Metodo

Definizione

Prova ad aggiornare la posizione di InteractionTracker applicando un'animazione.

Il metodo TryUpdatePositionWithAnimation aggiorna la posizione di InteractionTracker in base all'input CompositionAnimation come parametro. Questo metodo viene usato nelle situazioni in cui il movimento di InteractionTracker deve essere definito da un'animazione specifica, invece dell'esperienza tradizionale di inerzia. TryUpdatePositionWithAnimation può essere chiamato dallo stato Idle o Inertia. In questo modo, la posizione di InteractionTracker verrà guidata dall'animazione definita e immettere lo stato CustomAnimation.

public:
 virtual int TryUpdatePositionWithAnimation(CompositionAnimation ^ animation) = TryUpdatePositionWithAnimation;
int TryUpdatePositionWithAnimation(CompositionAnimation const& animation);
public int TryUpdatePositionWithAnimation(CompositionAnimation animation);
function tryUpdatePositionWithAnimation(animation)
Public Function TryUpdatePositionWithAnimation (animation As CompositionAnimation) As Integer

Parametri

animation
CompositionAnimation

Animazione da applicare a InteractionTracker.

Restituisce

Int32

int

Restituisce l'ID richiesta. Nelle transizioni di stato, la richiesta che ha causato la modifica dello stato verrà inclusa negli argomenti. Questi ID inizieranno da 1 e aumentano con ogni chiamata try durante la durata dell'applicazione.

Esempio

void CustomAnimationForIT(Vector3 newPosition)
{
  // Create a cubic bezier easing function that will be used in the KeyFrames
  CompositionEasingFunction cubicBezier = _compositor.CreateCubicBezierEasingFunction(new Vector2(.17f, .67f), new Vector2(1f, 1f);

  // Create the Vector3 KFA
  Vector3KeyFrameAnimation kfa = _compositor.CreateVector3KeyFrameAnimation();
  kfa.Duration = TimeSpan.FromSeconds(3);

  // Create the KeyFrames
  kfa.InsertKeyFrame(1.0f, newPosition, cubicBezier);

  // Update InteractionTracker position using this animation
  _tracker.TryUpdatePositionWithAnimation(kfa);
}

Commenti

Quando crei l'animazione con cui vuoi aggiornare la posizione di InteractionTracker , non devi chiamare Microsoft.UI.Composition.CompositionObject.StartAnimation. Il sistema si occuperà di questo dietro le quinte dopo che l'animazione viene passata tramite TryUpdatePositionWithAnimation.

Quando si definisce l'animazione che anima la posizione di InteractionTracker , assicurarsi di usare Vector3KeyFrameAnimation o ExpressionAnimation che si risolve in vector3.

La tabella seguente riepiloga il comportamento previsto quando questo metodo viene chiamato in uno stato specifico:

Stato correnteRisultato
IdleL'animazione richiesta inizia sulla proprietà richiesta, le modifiche dello stato a CustomAnimation
InterazioneRichiesta ignorata
InerziaL'animazione richiesta inizia sulla proprietà richiesta, le modifiche dello stato a CustomAnimation
CustomAnimationL'animazione corrente si arresta e viene avviata una nuova animazione richiesta sulla proprietà richiesta, lo stato entra di nuovo in CustomAnimation

Si applica a