예제 #1
0
        private void UpdateAnimation()
        {
            // if they are currently moving
            if (Math.Abs(Velocity.X) > 0 || Math.Abs(Velocity.Y) > 0)
            {
                // find out what directions they are actually moving...
                var actualDir = ParseActualDirection(Velocity.X, Velocity.Y);
                // ... and what direction the animation is facing
                var currentDir = StringToDirection(Sprite.GetAnimation().Split(' ')[1]);

                Direction = actualDir[0];

                // if they aren't facing a valid direction, correct it
                if (!actualDir.Contains(currentDir))
                {
                    Sprite.SetAnimation(String.Format("walking {0}", actualDir[0].ToString().ToLower()));
                }

                // if the animation is standing, change it to moving
                if (Sprite.GetAnimation().Split(' ')[0] == "standing")
                {
                    Sprite.SetAnimation(Sprite.GetAnimation().Replace("standing", "walking"));
                }
            }
            else
            {
                // make sure they are standing if they have no velocity
                Sprite.SetAnimation("standing " + Direction.ToString().ToLower());
            }
        }
예제 #2
0
 protected void SetIcon(string iconName, int i)
 {
     Icon = new SpriteObject(Game, null, "Abilities/" + iconName)
     {
         Height = 50, Width = 50
     };
     Icon.AddAnimation(Name,
                       new SpriteAnimation
     {
         StartRow   = 0,
         StartCol   = i * 50,
         FrameCount = 1,
         FrameRate  = 1,
         Size       = new Rectangle(0, 0, 50, 50)
     });
     Icon.SetAnimation(Name);
 }