示例#1
0
        /// <summary>
        /// This function loads the content for the player.
        /// </summary>
        /// <param name="playerTextures">player animation textures</param>
        /// <param name="playerSounds">sound effects</param>
        public void LoadContent(Texture2D[] playerTextures, SoundEffect[] playerSounds)
        {
            //load animated textures
            idleAnimation = new Animation(playerTextures[0], 0.1f, true);
            jumpAnimation = new Animation(playerTextures[1], 0.1f, true);
            runAnimation = new Animation(playerTextures[2], 0.1f, true);

            //set the local boundaries for the animation textures
            int width = idleAnimation.FrameWidth;
            int left = 0;
            int height = idleAnimation.FrameHeight;
            int top = 0;
            localBounds = new Rectangle(left, top, width, height);

            //load sounds
            jumpSound = playerSounds[0];
            killedSound = playerSounds[1];

            Reset(); //set the player
        }
示例#2
0
文件: Enemy.cs 项目: egmcdonald/radio
        /// <summary>
        /// This functions loads the content for the enemy object.
        /// </summary>
        public 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)
        }
示例#3
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;
        }