CompositionObject.StartAnimationGroup(ICompositionAnimationBase) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
成立了一個動畫小組。
CompositionObject 上的 StartAnimationGroup 方法可以讓你啟動 CompositionAnimationGroup。 群組中的所有動畫都會同時在物件上啟動。
public:
virtual void StartAnimationGroup(ICompositionAnimationBase ^ value) = StartAnimationGroup;
void StartAnimationGroup(ICompositionAnimationBase const& value);
public void StartAnimationGroup(ICompositionAnimationBase value);
function startAnimationGroup(value)
Public Sub StartAnimationGroup (value As ICompositionAnimationBase)
參數
先從動畫組開始。
範例
class PropertyAnimation
{
PropertyAnimation(Compositor compositor, SpriteVisual heroVisual)
{
// Define ImplicitAnimations
ImplicitAnimationCollection implicitAnimations = compositor.CreateImplicitAnimationCollection();
// Animate multiple properties on the target when the “Offset” property changes.
CompositionAnimationGroup animationGroup = compositor.CreateCompositionAnimationGroup();
animationGroup.Add(CreateSizeAnimation(compositor));
animationGroup.Add(CreateRotationAnimation(compositor));
// Set the CenterPoint so that rotation will be around the center
heroVisual.CenterPoint = new Vector3((heroVisual.Size.X/2.0f), (heroVisual.Size.Y/2.0f), 0.0f);
// Start AnimationGroup
heroVisual.StartAnimationGroup(animationGroup);
}
Vector2KeyFrameAnimation CreateSizeAnimation(Compositor compositor)
{
Vector2KeyFrameAnimation animation = compositor.CreateVector2KeyFrameAnimation();
CubicBezierEasingFunction easing = compositor.CreateCubicBezierEasingFunction(new Vector2(0.80f, 0.0f), new Vector2(0.95f, 1.0f));
// value (as the animation will target on the “Size” property).
animation.InsertExpressionKeyFrame(0f, "this.StartingValue", easing);
animation.InsertExpressionKeyFrame(1f, "this.StartingValue * 2", easing);
animation.Duration = TimeSpan.FromSeconds(0.25);
animation.Target = “Size”;
return animation;
}
ScalarKeyFrameAnimation CreateRotationAnimation(Compositor compositor)
{
ScalarKeyFrameAnimation animation = compositor.CreateScalarKeyFrameAnimation();
// Create KeyFrameAnimation to animate RotationAngleInDegrees by 90 degrees.
animation.InsertExpressionKeyFrame(0f, "this.StartingValue”);
animation.InsertExpressionKeyFrame(1f, "this.StartingValue + 90.0f”);
animation.Duration = TimeSpan.FromSeconds(0.25);
animation.Target = “RotationAngleInDegrees”;
return animation;
}
}
備註
StartAnimationGroup 以 CompositionAnimationGroup 為參數,讓該群組中所有動畫同時在物件上啟動。 群組中的 CompositionAnimation 應該會被指派給 Target 屬性值。
要取得所有動畫的已完成事件,應從註冊為已完成事件的 CompositionScopedBatch 呼叫 StartAnimationGroup。