public CompositeAnimationSample(Microsoft.Xna.Framework.Game game) : base(game) { Rectangle bounds = GraphicsService.GraphicsDevice.Viewport.TitleSafeArea; // A single from/to animation. SingleFromToByAnimation fromToAnimation = new SingleFromToByAnimation { From = bounds.Top + 200, To = bounds.Bottom - 200, Duration = TimeSpan.FromSeconds(2), EasingFunction = new SineEase { Mode = EasingMode.EaseInOut }, }; // Create an animation that oscillates forever. AnimationClip <float> loopedSingleAnimationX = new AnimationClip <float>(fromToAnimation) { LoopBehavior = LoopBehavior.Oscillate, Duration = TimeSpan.MaxValue, }; // Create an animation that oscillates forever. The animations starts 1 second into // the fromToAnimation - that means, loopedSingleAnimationX is 1 second "behind" this // animation. AnimationClip <float> loopedSingleAnimationY = new AnimationClip <float>(fromToAnimation) { LoopBehavior = LoopBehavior.Oscillate, Duration = TimeSpan.MaxValue, Delay = TimeSpan.FromSeconds(-1), }; // Create a composite animation that combines the two float animations to animate // a Vector2 value. Vector2Animation compositeAnimation = new Vector2Animation(loopedSingleAnimationX, loopedSingleAnimationY); // Start animation. AnimationService.StartAnimation(compositeAnimation, _animatablePosition).UpdateAndApply(); }
protected override void LoadContent() { Rectangle bounds = GraphicsDevice.Viewport.TitleSafeArea; // A single from/to animation. SingleFromToByAnimation fromToAnimation = new SingleFromToByAnimation { From = bounds.Top + 200, To = bounds.Bottom - 200, Duration = TimeSpan.FromSeconds(2), EasingFunction = new SineEase { Mode = EasingMode.EaseInOut }, }; // Create an animation that oscillates forever. AnimationClip<float> loopedSingleAnimationX = new AnimationClip<float>(fromToAnimation) { LoopBehavior = LoopBehavior.Oscillate, Duration = TimeSpan.MaxValue, }; // Create an animation that oscillates forever. The animations starts 1 second into // the fromToAnimation - that means, loopedSingleAnimationX is 1 second "behind" this // animation. AnimationClip<float> loopedSingleAnimationY = new AnimationClip<float>(fromToAnimation) { LoopBehavior = LoopBehavior.Oscillate, Duration = TimeSpan.MaxValue, Delay = TimeSpan.FromSeconds(-1), }; // Create a composite animation that combines the two float animations to animate // a Vector2 value. Vector2Animation compositeAnimation = new Vector2Animation(loopedSingleAnimationX, loopedSingleAnimationY); // Start animation. AnimationService.StartAnimation(compositeAnimation, _animatablePosition); base.LoadContent(); }
private void SetupDataAnimations() { if (this.AnimationsSetup || this.Client.ClientData == null) { return; } var client = this.Client; var data = client.ClientData; this.heightString = $"Height: {data.Height}"; this.shoeString = $"Shoe size: {data.ShoeSize}"; this.overlayAnimation = new ColorAnimation(Color.White, client.Color, TimeSpan.FromSeconds(1.5)); float alpha = 0.7f; this.nameOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2)); this.namePositionAnimation = new Vector2Animation(new Vector2(0, -30), new Vector2(50, -30), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2)); this.nameStringAnimation = new StringAnimation("", data.Name, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2)); this.surnameOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3)); this.surnamePositionAnimation = new Vector2Animation(new Vector2(0, -5), new Vector2(50, -5), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3)); this.surnameStringAnimation = new StringAnimation("", data.Surname, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3)); this.emailOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4)); this.emailPositionAnimation = new Vector2Animation(new Vector2(0, 20), new Vector2(50, 20), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4)); this.emailStringAnimation = new StringAnimation("", data.Email, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4)); this.heightOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5)); this.heightPositionAnimation = new Vector2Animation(new Vector2(-40, 0), new Vector2(-40, 120), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5)); this.heightStringAnimation = new StringAnimation("", heightString, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5)); this.shoeSizeOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6)); this.shoeSizePositionAnimation = new Vector2Animation(new Vector2(-40, 100), new Vector2(-40, 150), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6)); this.shoeSizeStringAnimation = new StringAnimation("", shoeString, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6)); }
public void ApplyVector2ToText(Text text) { Vector2Animation vector2Animation = ((Vector2Animation)simpleAnimationsManager.GetAnimation("Vector2")); text.text = vector2Animation.vector2ToAnimate.ToString(); }
private void SetupDataAnimations() { if (this.AnimationsSetup || this.Client.ClientData == null) return; var client = this.Client; var data = client.ClientData; this.heightString = $"Height: {data.Height}"; this.shoeString = $"Shoe size: {data.ShoeSize}"; this.overlayAnimation = new ColorAnimation(Color.White, client.Color, TimeSpan.FromSeconds(1.5)); float alpha = 0.7f; this.nameOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2)); this.namePositionAnimation = new Vector2Animation(new Vector2(0, -30), new Vector2(50, -30), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2)); this.nameStringAnimation = new StringAnimation("", data.Name, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(2)); this.surnameOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3)); this.surnamePositionAnimation = new Vector2Animation(new Vector2(0, -5), new Vector2(50, -5), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3)); this.surnameStringAnimation = new StringAnimation("", data.Surname, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(3)); this.emailOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4)); this.emailPositionAnimation = new Vector2Animation(new Vector2(0, 20), new Vector2(50, 20), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4)); this.emailStringAnimation = new StringAnimation("", data.Email, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(4)); this.heightOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5)); this.heightPositionAnimation = new Vector2Animation(new Vector2(-40, 0), new Vector2(-40, 120), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5)); this.heightStringAnimation = new StringAnimation("", heightString, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(5)); this.shoeSizeOpacityAnimation = new FloatAnimation(0.0f, alpha, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6)); this.shoeSizePositionAnimation = new Vector2Animation(new Vector2(-40, 100), new Vector2(-40, 150), TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6)); this.shoeSizeStringAnimation = new StringAnimation("", shoeString, TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(6)); }