PlayAnimation() public method

Begins or continues playback of an animation.
public PlayAnimation ( Animation animation ) : void
animation Animation
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public void LoadContent(string spriteSet)
        {
            // Load animations.
            spriteSet     = "Sprites/" + spriteSet + "/";
            runAnimation  = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Run"), 0.1f, true);
            idleAnimation = new Animation(Level.Content.Load <Texture2D>(spriteSet + "Idle"), 0.15f, true);
            sprite.PlayAnimation(idleAnimation);

            // Calculate bounds within texture size.
            int width  = (int)(idleAnimation.FrameWidth * 0.35);
            int left   = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.7);
            int top    = idleAnimation.FrameHeight - height;

            localBounds = new Rectangle(left, top, width, height);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Resets the player to life.
 /// </summary>
 /// <param name="position">The position to come to life at.</param>
 public void Reset(Vector2 position)
 {
     Position = position;
     Velocity = Vector2.Zero;
     isAlive  = true;
     sprite.PlayAnimation(idleAnimation);
 }