Exemple #1
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animations.
            runAnimation = new Animation(Level.Content.Load<Texture2D>("Farmer/Run"), 0.1f, true);
            idleAnimation = new Animation(Level.Content.Load<Texture2D>("Farmer/Idle"), 0.15f, true);
            deathAnimation = new Animation(Level.Content.Load<Texture2D>("Farmer/Die"), 0.1f, false);
            sprite.PlayAnimation(idleAnimation);

            // Load Sounds
            // TODO: Add sound :(
        }
        /// <summary>
        /// Begins or continues playback of an animation.
        /// </summary>
        public void PlayAnimation(Animation animation)
        {
            // If this animation is already running, do not restart it.
            if (Animation == animation)
                return;

            // Start the new animation.
            this.animation = animation;
            this.frameIndex = 0;
            this.time = 0.0f;
        }