KeyFrameAnimation.Direction Proprietà

Definizione

Direzione in cui viene riprodotta l'animazione.

La proprietà Direction consente di guidare l'animazione dall'inizio alla fine o dalla fine all'inizio o dall'inizio o dall'inizio o dalla fine per iniziare se l'animazione ha un IterationCount maggiore di uno. In questo modo è possibile personalizzare facilmente le definizioni di animazione.

public:
 property AnimationDirection Direction { AnimationDirection get(); void set(AnimationDirection value); };
AnimationDirection Direction();

void Direction(AnimationDirection value);
public AnimationDirection Direction { get; set; }
var animationDirection = keyFrameAnimation.direction;
keyFrameAnimation.direction = animationDirection;
Public Property Direction As AnimationDirection

Valore della proprietà

Direzione in cui viene riprodotta l'animazione.

Esempio

AnimationDirection è Normale

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is normal i.e. forward. 
    animation.Direction = AnimationDirection.Normal; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

AnimationDirection è inverso

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is Reverse i.e. end to start. 
    animation.Direction = AnimationDirection.Reverse; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

AnimationDirection è Alternate

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is alternate i.e. start to end and then end to start and so on. 
    animation.Direction = AnimationDirection.Alternate; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

AnimationDirection è AlternateReverse

class Direction 
{ 
  Direction(Compositor compositor, SpriteVisual heroVisual) 
  { 
    Vector3KeyFrameAnimation animation = compositor.CreateVector3KeyFrameAnimation(); 
    animation.InsertKeyFrame(0f, new Vector3(0f,0f,0f)); 
    animation.InsertKeyFrame(1f, new Vector3(20f,20f,0f)); 
    animation.Duration = TimeSpan.FromSeconds(0.25); 

    // Run animation for 4 times 
    animation.IterationCount = 4; 

    // Direction of animation is alternate-reverse i.e. end to start and then start to end and so on. 
    animation.Direction = AnimationDirection.AlternateReverse; 

    heroVisual.StartAnimation("Offset", animation); 
  } 
} 

Commenti

Data un'animazione di offset con un numero di iterazioni pari a 3 e due fotogrammi chiave (0 e 1) con un valore Vector3(5,5,5) per il fotogramma chiave 0 e un valore Vector3(20,20,20) per il fotogramma chiave 1, nella tabella seguente viene illustrato il comportamento di animazione con valori diversi per Direction.

DirectionComportamento animazione
NormalL'animazione inizierà dal valore di offset Vector3(5,5,5) e passerà a Vector3(20,20,20), ripetendo 3 volte sempre a partire da (5,5,5).
ReverseL'animazione inizierà in senso inverso e offset (20,20,20) e passa a (5,5,5) ripetendo 3 volte sempre a partire da (20,20,20).
AlternatePer la prima iterazione, l'animazione inizierà dal valore di offset (5,5,5) e passa a (20,20,20). Nella seconda animazione di iterazione l'animazione inizierà dal valore di offset (20,20,20) e passa a (5,5,5). Nella terza e ultima iterazione l'animazione inizierà dall'offset (5,5,5) e passerà a (20,20,20).
AlternateReversePer la prima iterazione, l'animazione inizierà dal valore di offset (20,20,20) e passa a (5,5,5). Nella seconda iterazione l'animazione inizierà dal valore di offset (5,5,5) e passerà a (20, 20, 20). Nella terza e ultima iterazione l'animazione inizierà dall'offset (20, 20, 20) e passa a (5,5,5).

Si applica a