/// <summary> /// Perform the animation when the child's height has changed. /// </summary> /// <param name="h"></param> /// <returns></returns> private double AnimatedResize(Double h) { double delta = targetHeight - h; Animation.Animation animation = HeightAnimation as Animation.Animation; if (animation == null) { animation = CreateAnimation(); } targetHeight = h; //animation.From = delta; //animation.To = 0; //this.BeginAnimation(AnimationDecorator.HeightOffsetProperty, animation); animation.FillMode = FillMode.Backward; KeyFrame keyFrame = new KeyFrame(); keyFrame.Cue = new Cue(0); keyFrame.Setters.Add(new Setter(AnimationDecorator.HeightOffsetProperty, delta)); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.Cue = new Cue(1); keyFrame.Setters.Add(new Setter(AnimationDecorator.HeightOffsetProperty, 0)); animation.Children.Add(keyFrame); animation.RunAsync(this); return(delta); }
/// <summary> /// creates the hide animation /// </summary> /// <returns></returns> private Animation.Animation CreateHideAnimation() { Animation.Animation animation = new Animation.Animation(); animation.Duration = TimeSpan.FromMilliseconds(100); animation.FillMode = Animation.FillMode.None; KeyFrame keyFrame = new KeyFrame(); keyFrame.KeyTime = TimeSpan.FromMilliseconds(0); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 1d }); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.KeyTime = TimeSpan.FromMilliseconds(100); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 0d }); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.KeyTime = TimeSpan.FromMilliseconds(100); keyFrame.Setters.Add(new Setter { Property = IsVisibleProperty, Value = false }); animation.Children.Add(keyFrame); return(animation); }
public Worm(Team team, int id, int x, int y) { Name = "Worm" + id; Team = team; Health = 100; Start = new Point(x, y); Current = Start; var Fixture = new Fixture(); Fixture.Friction = 1.0f; Fixture.Restitution = 0.1f; Fixture.Shape = new CircleShape(24, 10); Body = BodyFactory.CreateRectangle(Physics.World, 31, 31, 1.0f); Body.BodyType = BodyType.Dynamic; Body.CollidesWith = Category.All; Body.CollisionCategories = Category.All; Body.FixedRotation = true; AnimState = AnimState.Idle; Animation = AnimManager.Animations[0]; }
private void UpdateThumb() { if (_ThumbTranslate != null && _SwitchTrack != null && _ThumbIndicator != null) { double destination = IsChecked.GetValueOrDefault() ? Width - (_SwitchTrack.Margin.Left + _SwitchTrack.Margin.Right + _ThumbIndicator.Width + _ThumbIndicator.Margin.Left + _ThumbIndicator.Margin.Right) : 0; _thumbAnimation = new Animation.Animation(); //_thumbAnimation.To = destination; _thumbAnimation.Duration = TimeSpan.FromMilliseconds(500); //_thumbAnimation.Easing = new ExponentialEase() { Exponent = 9 }; _thumbAnimation.FillMode = Animation.FillMode.Backward; _thumbAnimation.PropertyChanged += (o, e) => { //if(e.Property.Name== nameof(Animation.Animation.) }; //_ThumbTranslate. //AnimationTimeline currentAnimation = _thumbAnimation; //_thumbAnimation.Completed += (sender, e) => { // if (_thumbAnimation != null && currentAnimation == _thumbAnimation) // { // _ThumbTranslate.X = destination; // _thumbAnimation = null; // } //}; //_ThumbTranslate.BeginAnimation(TranslateTransform.XProperty, _thumbAnimation); } }
public Sprite(Vector2 position, XNATools.SpriteEngine.Collections.Animations animations) { this.position = position; this.prevPosition = position; this.animations = animations; this.currentAnimation = this.animations.StandbyAnimation; }
private Animation.Animation CreateAnimation() { Animation.Animation animation = new Animation.Animation(); //animation.DecelerationRatio = 0.8; animation.Duration = Duration; return(animation); }
protected void ChangeAnimation(Animation.Animation animation) { if (currentAnimation != animation) { previousAnimation = currentAnimation; previousAnimation.CurrentFrame = 0; currentAnimation = animation; } }
public static void Init(Microsoft.Xna.Framework.Content.ContentManager content) { var WormIdle = content.Load <Texture2D>("Sprites\\widle"); Animations[0] = new Animation.Animation("Idle", new SpriteImage(WormIdle, 1), false); var WormWalk = content.Load <Texture2D>("Sprites\\wwalk"); Animations[1] = new Animation.Animation("Walk", new SpriteImage(WormWalk, 14), true); }
/// <summary> /// creates default in or out animation /// </summary> /// <param name="inDirection"></param> /// <returns></returns> private Animation.Animation CreateDefaultAnimation(bool inDirection) { Animation.Animation animation = new Animation.Animation(); if (inDirection) { animation.IterationCount = new IterationCount(1); KeyFrame keyFrame = new KeyFrame(); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 1d }); keyFrame.Cue = new Cue(0d); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 0d }); keyFrame.Cue = new Cue(1d); animation.Children.Add(keyFrame); } else { animation.FillMode = FillMode.None; animation.IterationCount = new IterationCount(1); KeyFrame keyFrame = new KeyFrame(); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 0d }); keyFrame.Cue = new Cue(0d); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 1d }); keyFrame.Cue = new Cue(1d); animation.Children.Add(keyFrame); } return(animation); }
public override void LoadXmlDoc(System.Xml.XmlDocument x) { foreach (XmlNode n in x.DocumentElement.ChildNodes) { string val = n.InnerText.Trim(); //System.Windows.Forms.MessageBox.Show(n.Name + " : " + val); switch (n.Name) { case "animation": Animation = new Animation.Animation(Helpers.NodeToDoc(n)); break; case "type": switch (val) { case "maincharacter": @Type = ActorType.MainCharacter; break; case "shark": @Type = ActorType.Shark; break; case "taffy": @Type = ActorType.Taffy; break; case "rock": @Type = ActorType.Rock; break; } break; case "x": Position.X = Convert.ToSingle(val); break; case "y": Position.Y = Convert.ToSingle(val); break; } } }
private void _DraggingThumb_DragStarted(object sender, VectorEventArgs e) { if (_DraggingThumb.IsPointerOver == false) { _lastDragPosition = null; _isDragging = false; return; } if (_ThumbTranslate != null) { //_ThumbTranslate.BeginAnimation(TranslateTransform.XProperty, null); double destination = IsChecked.GetValueOrDefault() ? Width - (_SwitchTrack.Margin.Left + _SwitchTrack.Margin.Right + _ThumbIndicator.Width + _ThumbIndicator.Margin.Left + _ThumbIndicator.Margin.Right) : 0; _ThumbTranslate.X = destination; _thumbAnimation = null; } _lastDragPosition = _ThumbTranslate.X; _isDragging = false; }
public void Update(GameTime gameTime) { Animation.Update(gameTime); if (AnimState == AnimState.Walking) { Animation = AnimManager.Animations[1]; if (Direction == Direction.left) { Body.Position = new Vector2(Body.Position.X - 1, Body.Position.Y); } else if (Direction == Direction.right) { Body.Position = new Vector2(Body.Position.X + 1, Body.Position.Y); } } else if (AnimState == AnimState.Jumping) { var forces = new Vector2((int)Direction, -2); Body.ApplyLinearImpulse(forces); } else { Animation = AnimManager.Animations[0]; } if (Body.Position.X > 0 && Body.Position.Y > 0) { Current = new Point((int)Body.Position.X, (int)Body.Position.Y); if (Body.Position.Y > 696) { Body.Position = new Vector2(Start.X + 1, Start.Y); } } }
/// <summary> /// creates the show animation /// </summary> /// <returns></returns> private Animation.Animation CreateShowAnimation() { Animation.Animation animation = new Animation.Animation(); animation.Duration = TimeSpan.FromMilliseconds(200); animation.FillMode = Animation.FillMode.Forward; KeyFrame keyFrame = new KeyFrame(); //keyFrame.KeyTime = TimeSpan.FromMilliseconds(0); keyFrame.Cue = new Cue(0d); keyFrame.Setters.Add(new Setter { Property = IsVisibleProperty, Value = true }); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); //keyFrame.KeyTime = TimeSpan.FromMilliseconds(0); keyFrame.Cue = new Cue(0d); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 0d }); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); //keyFrame.KeyTime = TimeSpan.FromMilliseconds(200); keyFrame.Cue = new Cue(1d); keyFrame.Setters.Add(new Setter { Property = OpacityProperty, Value = 1d }); animation.Children.Add(keyFrame); return(animation); }
private async void AnimateExpandedChanged(bool expanded) { if (Child != null) { animating = true; if (YOffset > 0) { YOffset = 0; } if (-YOffset > Child.DesiredSize.Height) { YOffset = -Child.DesiredSize.Height; } Animation.Animation animation = HeightAnimation as Animation.Animation; if (animation == null) { animation = CreateAnimation(); } animation.FillMode = expanded ? FillMode.Forward : FillMode.Backward; double val = expanded ? 0 : -Child.DesiredSize.Height; KeyFrame keyFrame = null; if (expanded) { keyFrame = new KeyFrame(); keyFrame.Cue = new Cue(0); keyFrame.Setters.Add(new Setter(AnimationDecorator.YOffsetProperty, YOffset)); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.Cue = new Cue(1); keyFrame.Setters.Add(new Setter(AnimationDecorator.YOffsetProperty, val)); animation.Children.Add(keyFrame); } else { keyFrame = new KeyFrame(); keyFrame.Cue = new Cue(1); keyFrame.Setters.Add(new Setter(AnimationDecorator.YOffsetProperty, val)); animation.Children.Add(keyFrame); keyFrame = new KeyFrame(); keyFrame.Cue = new Cue(0); keyFrame.Setters.Add(new Setter(AnimationDecorator.YOffsetProperty, 1d)); animation.Children.Add(keyFrame); } //animation.From = null; //animation.To = //animation.Completed += new EventHandler(animation_Completed); //this.BeginAnimation(AnimationDecorator.YOffsetProperty, animation); if (OpacityAnimation) { val = expanded ? 1 : 0; keyFrame.Setters.Add(new Setter(AnimationDecorator.AnimationOpacityProperty, val)); animation.Children.Add(keyFrame); //this.BeginAnimation(AnimationDecorator.AnimationOpacityProperty, animation); } await Task.WhenAll(new Task[] { animation.RunAsync(this) }).ContinueWith(x => { animating = false; }); } else { YOffset = int.MinValue; } }
/// <summary> /// This initializes the animation, if you want to play it set bPlayAnimation = true; /// </summary> /// <param name="startFrame"></param> /// <param name="framecountPerAnimation"></param> /// <param name="animationSpriteSheet"></param> /// <param name="frameTime"></param> public void InitializeAnimation(List <Rectangle> startFrame, List <int> framecountPerAnimation, Texture2D animationSpriteSheet, double frameTime = 500) { shapeAnimation = new Animation.Animation(startFrame, framecountPerAnimation, animationSpriteSheet, frameTime); bHasAnimations = true; }
/// <summary> /// Called when CurrentFrame property has changed. /// </summary> /// <param name="oldValue">Old property value</param> /// <param name="newValue">New property value</param> protected virtual void OnCurrentFrameChanged(int oldValue, int newValue) { _LastFrame = oldValue; if (_AnimationEnabled && _AnimationDuration > 0 && !GetDesignMode()) // Animate transition from current frame to new frame { DisposeCurrentAnimation(); int targetValue = _TileSize.Height; Animation.AnimationInt anim = new DevComponents.DotNetBar.Animation.AnimationInt(new Animation.AnimationRequest(this, "CurrentFrameOffset", targetValue, 0), Animation.AnimationEasing.EaseOutExpo, _AnimationDuration); _CurrentAnimation = anim; anim.Start(); } else this.Refresh(); //OnPropertyChanged(new PropertyChangedEventArgs("CurrentFrame")); }
protected override void onTick() { Velocity += Acceleration * (float)Execution.MSPF; float a = 0.0005f; float div = 1.1f; if (@Type == ActorType.MainCharacter) { if (Velocity.X > speedlimit) { Velocity.X = speedlimit; } if (Velocity.X < -speedlimit) { Velocity.X = -speedlimit; } if (Velocity.Y > speedlimit) { Velocity.Y = speedlimit; } if (Velocity.Y < -speedlimit) { Velocity.Y = -speedlimit; } } LastPosition = new Vector2f(Position.X, Position.Y); Position += Velocity * (float)Execution.MSPF; DeltaPosition = new Vector2f(Position.X - LastPosition.X, Position.Y - LastPosition.Y); @Animation.Tick(); switch (@Type) { case ActorType.Rock: if (Collision.CollidingWith(StaticResources.State.MainCharacter.Collision)) { StaticResources.State.MainCharacter.GoBack(); } break; case ActorType.MainCharacter: if (Velocity.X >= 0) { Frame.MakeUnflipped(); } else if (Velocity.X <= 0) { Frame.MakeFlipped(); } if (Keyboard.IsKeyPressed(Keyboard.Key.W)) { Acceleration.Y = -a; } else if (Keyboard.IsKeyPressed(Keyboard.Key.S)) { Acceleration.Y = a; } else { Acceleration.Y = 0; Velocity.Y /= div; } if (Keyboard.IsKeyPressed(Keyboard.Key.D)) { Acceleration.X = a; } else if (Keyboard.IsKeyPressed(Keyboard.Key.A)) { Acceleration.X = -a; } else { Acceleration.X = 0; Velocity.X /= div; } if (Seq != null) { switch (Seq.Seq) { case Sequences.Default: Animation = Animations.Idle; break; case Sequences.Spin: Animation = Animations.Spinny; break; } } else { Animation = Animations.Idle; } break; case ActorType.Shark: if (Collision.CollidingWith(StaticResources.State.MainCharacter.Collision)) { if (StaticResources.State.MainCharacter.Seq != null) { if (StaticResources.State.MainCharacter.Seq.Seq == Sequences.Spin) { Seq = null; Velocity = new Vector2f(0.8f, -0.8f); SharkHit = true; return; } } if (!SharkHit) { System.Windows.Forms.MessageBox.Show("You died!"); Environment.Exit(0); StaticResources.State.MainCharacter.GoBack(); } } if (!SharkHit) { if (Seq == null) { if (Velocity.X >= 0) { Velocity.X = -0.1f; Seq = new Sequence(Sequences.SharkLeft, 3000, 0); } else { Velocity.X = 0.1f; Seq = new Sequence(Sequences.SharkRight, 3000, 0); } } if (Velocity.X <= 0) { Sprite.Scale = new Vector2f(1.0f, 1.0f); } else if (Velocity.X >= 0) { Sprite.Scale = new Vector2f(-1.0f, 1.0f); } } else { Sprite.Scale = new Vector2f(Sprite.Scale.X / 2, Sprite.Scale.Y / 2); } break; case ActorType.Taffy: if (!Hidden && Collision.CollidingWith(StaticResources.State.MainCharacter.Collision)) { StaticResources.State.Candies++; Hidden = true; Sound.Play("player/powerup" + Helpers.Rnd.Next(1, 3), 50); //System.Windows.Forms.MessageBox.Show("aaa"); } break; } Sprite.Position = new Vector2f(Position.X, Position.Y); }
/// <summary> /// /// </summary> /// <param name="animation"></param> public void Add(Animation.Animation animation) { }
private void AnimationCompleted(object sender, EventArgs e) { //Console.WriteLine("{0} Animation Completed", DateTime.Now); Animation.Animation anim = _CurrentAnimation; _CurrentAnimation = null; if (anim != null) anim.Dispose(); if (!_IsOpen) { this.Visible = false; } _IsAnimating = false; }
/// <summary> /// Slides panel out of the view. /// </summary> private void SlideOutOfView() { Animation.Animation current = _CurrentAnimation; if (current != null) { current.Stop(); WaitForCurrentAnimationFinish(); } Rectangle bounds = this.Bounds; Rectangle targetBounds = GetSlideOutBounds(); if (_AnimationTime > 0 && this.Visible) { _IsAnimating = true; //BarFunctions.AnimateControl(this, true, _AnimationTime, bounds, targetBounds); Animation.AnimationRectangle anim = new DevComponents.DotNetBar.Animation.AnimationRectangle( new Animation.AnimationRequest(this, "Bounds", bounds, targetBounds), Animation.AnimationEasing.EaseOutExpo, _AnimationTime); anim.AnimationCompleted += new EventHandler(AnimationCompleted); anim.Start(); _CurrentAnimation = anim; //this.Visible = false; } else this.Bounds = targetBounds; _OpenBounds = bounds; if (_SlideOutButtonVisible) CreateSlideOutButton(); }
private void DisposeCurrentAnimation() { Animation.Animation anim = _CurrentAnimation; _CurrentAnimation = null; if (anim != null) { anim.Stop(); anim.Dispose(); } }
/// <summary> /// /// </summary> /// <param name="animation"></param> public void Remove(Animation.Animation animation) { }
public AnimatedSceneObject(string name, MutablePoint positionPoint, MutableSize size, Animation.Animation animation, Scene parent = null) : base(name, positionPoint, size, parent) { Animation = animation; Animation.Start(); // TODO ??? }