Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This functions loads the content for the enemy object.
        /// </summary>
        protected void LoadContent()
        {
            //initalise the animation objects
            fallAnimation = new Animation(enemyTextures[textureStart], 0.1f, true);
            idleAnimation = new Animation(enemyTextures[textureStart+1], 0.1f, true);
            runAnimation = new Animation(enemyTextures[textureStart+2], 0.1f, true);

            sprite.PlayAnimation(idleAnimation); //start with the idle animation

            int width = idleAnimation.FrameWidth;
            int left = 0;
            int height = idleAnimation.FrameHeight;
            int top = 0;
            localBounds = new Rectangle(left, top, width, height); //create the local bounds for the animation frames

            velocity = Vector2.Zero; //set velocity to zero (i.e. enemy does not move)
        }