Represents an animated texture.
Currently, this class assumes that each frame of animation is as wide as each animation is tall. The number of frames in the animation are inferred from this.
Esempio n. 1
0
        public void LoadContent()
        {
            int rand = PlatformerGame.RandomBetween(0, 100);
            if (rand >= 0 && rand <= 25)
            {
                idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/donut"), 0.1f, false);
            }
            else if (rand > 25 && rand <= 50)
            {
                idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/duff"), 0.1f, false, 71);
            }
            else if (rand > 50 && rand <= 75)
            {
                idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/chunli"), 0.1f, false, 40);
            }
            else if (rand > 75)
            {
                idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/winning"), 0.1f, false, 200);
            }
            sprite.PlayAnimation(idleAnimation);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 1.5);
            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);
        }
Esempio n. 2
0
 /// <summary>
 /// Loads the player sprite sheet and sounds.
 /// </summary>
 public void LoadContent()
 {
     // Load animated textures.
     baseGraphic = new Animation(Game.Content.Load<Texture2D>("Sprites/Weapons/shotgun"), 0.1f, false);
     muzzleFire = new Animation(Game.Content.Load<Texture2D>("Sprites/Weapons/shotgun_muzzle"), 0.01f, false);
     shotSound = Game.Content.Load<SoundEffect>("Sounds/shotgunBlastSound");
 }
Esempio n. 3
0
        public void PlayAnimation(Animation animation)
        {
            if (Animation == animation)
                return;

            this.animation = animation;
            FrameIndex = 0;
            Time = 0.0f;
        }
Esempio n. 4
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;
        }
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animated textures.
            bulletGraphic = new Animation(Game.Content.Load<Texture2D>("Sprites/Weapons/shell"), 0.1f, false);

            // Calculate bounds within texture size.
            int width = (int)(bulletGraphic.FrameWidth * 0.6);
            int left = ((bulletGraphic.FrameWidth - width) / 2) + 2;
            int height = (int)(bulletGraphic.FrameWidth * 0.8);
            int top = bulletGraphic.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 6
0
        /// <summary>
        /// Loads a particular spike sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            idleAnimation = new Animation(Level.Content.Load<Texture2D>("Tiles/spike"), 0.1f, false);
            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);
        }
Esempio n. 7
0
        public Actor(World world, Animation animation, Vector2 position, Vector2 bodySize)
        {
            _animation = animation;

            _capsuleCollider = BodyFactory.CreateCapsule(world, bodySize.Y * pixelToUnit, bodySize.X / 2 * pixelToUnit, 1);
            _capsuleCollider.BodyType = BodyType.Dynamic;
            _capsuleCollider.FixedRotation = true;
            _BodySize = bodySize;
            _Position = position;
            _capsuleCollider.Friction = 0; // doesn't effect X-motion because we assign it, directly

            _velocity = new Vector2(0, 5);
        }
Esempio n. 8
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animated textures.
            bulletGraphic = new Animation(Game.Content.Load<Texture2D>("Sprites/Weapons/firebreath"), 0.1f, true, 60);
            bulletSprite.PlayAnimation(bulletGraphic);

            // Calculate bounds within texture size.
            int width = (int)(bulletGraphic.FrameWidth * 0.4);
            int left = (bulletGraphic.FrameWidth - width) / 2;
            int height = (int)(bulletGraphic.FrameWidth * 0.8);
            int top = bulletGraphic.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 9
0
        /// <summary>
        /// Loads a particular knife sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            idleAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Weapons/knife_idle"), 0.1f, false, 50);
            attackAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Weapons/knife"), 0.1f, false, 50);
            sprite.PlayAnimation(idleAnimation);

            knifeSound = game.Content.Load<SoundEffect>("Sounds/knifeSound");

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = 10;
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
        public void LoadContent()
        {
            // Load animated textures.
            bulletGraphic = new Animation(Game.Content.Load<Texture2D>("Sprites/Weapons/explosion"), 0.1f, false);
            bulletSprite.PlayAnimation(bulletGraphic);

            bulletSprite.AnimationCompleted += new AnimationCompletedHanler(bulletSprite_AnimationCompleted);

            // Calculate bounds within texture size.
            int width = (int)(bulletGraphic.FrameWidth);
            int left = (bulletGraphic.FrameWidth - width) / 2;
            int height = (int)(bulletGraphic.FrameWidth);
            int top = bulletGraphic.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 11
0
 public override void Load(string xmlPath)
 {
     base.Load(xmlPath);
     Animations["Alive"].Looping = true;
     CurrentAnimation = new Animation(Animations["Alive"]);
 }
Esempio n. 12
0
 protected override void Kill()
 {
     IsAlive = false;
     
     CurrentAnimation = new Animation(Animations["Dead"]);
 }
Esempio n. 13
0
        public void LoadContent(string spriteSet)
        {
            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);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Die"), 0.07f, false);
            sprite.PlayAnimation(idleAnimation);

            int width = (int)(idleAnimation.FrameWidth * 0.35);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameHeight * 0.7);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 14
0
 /// <summary>
 /// Loads a particular object sprite sheet.
 /// </summary>
 public virtual void LoadContent()
 {
     // Load animations.
     string spriteSet = "Sprites/Objects/" + objectType;
     animation = new Animation(Session.GameplayScreen.ScreenManager.Game.Content.Load<Texture2D>(spriteSet), 0.1f, true, true);
     sprite.PlayAnimation(animation);
 }
 public void StopAnimation()
 {
     // Stop the animation
     this.animation = null;
     this.frameIndex = 0;
     this.time = 0.0f;
 }
Esempio n. 16
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animated textures.
            idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Idle"), 0.1f, true);
            runAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Run"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Jump"), 0.1f, false);
            celebrateAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Celebrate"), 0.1f, false);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.8);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);

            // Load sounds.
            killedSound = Level.Content.Load<SoundEffect>("Sounds/PlayerKilled");
            jumpSound = Level.Content.Load<SoundEffect>("Sounds/PlayerJump");
            fallSound = Level.Content.Load<SoundEffect>("Sounds/PlayerFall");
        }
Esempio n. 17
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public void LoadContent(string spriteSet)
        {
            // Load animations.
            String tempSprite = spriteSet;
            spriteSet = "Sprites/" + spriteSet + "/";
            /*if (tempSprite.Equals("MonsterA") || tempSprite.Equals("MonsterB"))
            {
                gawkAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Gawk"), 0.1f, true);
            }
            else if (tempSprite.Equals("MonsterC"))
                deathAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Death"), 0.1f, false);*/

            runAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Run"), 0.1f, true);
            idleAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + "Idle"), 0.1f, true);
            runAnimation.setWindowWidth(64);
            idleAnimation.setWindowWidth(64);

            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);
        }
Esempio n. 18
0
        /// <summary>
        /// Loads a particular knife sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            this.Reset();

            explosion = new GrenadeExplosion(game, position, _player);

            idleAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Weapons/bomb"), 0.1f, true);
            sprite.PlayAnimation(idleAnimation);

            explosionSound = game.Content.Load<SoundEffect>("Sounds/explosionSound");

            throwSound = game.Content.Load<SoundEffect>("Sounds/throwSound");
            bombSound = game.Content.Load<SoundEffect>("Sounds/bombSound");
            bombSoundInstance = bombSound.CreateInstance();
            bombSoundInstance.IsLooped = true;
            bombSoundInstance.Volume = 0.55f;

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = 10;
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 19
0
        /// <summary>
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public virtual 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);
        }
Esempio n. 20
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent(ContentManager content)
        {
            // Load animated textures.
            idleRightAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Idle-Right"), 0.1f, true);
            idleLeftAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Idle-Left"), 0.1f, true);
            runRightAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Walk-Right"), 0.1f, true);
            runLeftAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Walk-Left"), 0.1f, true);
            fallRightAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Fall-Right"), 0.15f, true);
            fallLeftAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Fall-Left"), 0.15f, true);
            jumpRightAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Jump-Right"), 0.05f, delegate
            {
                sprite.PlayAnimation(fallRightAnimation);
            });
            jumpLeftAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Jump-Left"), 0.05f, delegate
            {
                sprite.PlayAnimation(fallLeftAnimation);
            });
            dieRightAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Spiked-Right"), 0.05f, false);
            dieLeftAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Spiked-Left"), 0.05f, false);
            drownRightAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Drown-Right"), 0.1f, true);
            drownLeftAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Drown-Left"), 0.1f, true);

            ladderUpAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Ladder"), 0.15f, true);
            ladderDownAnimation = new Animation(content.Load<Texture2D>("Sprites/Player/Ladder"), 0.1f, true);

            // Calculate bounds within texture size.
            float width = idleLeftAnimation.FrameWidth * 0.4f;
            float left = (idleLeftAnimation.FrameWidth - width) / 2;
            float height = idleLeftAnimation.FrameWidth * 0.8f;
            float top = idleLeftAnimation.FrameHeight - height;
            localBounds = new RectangleF(left, top, width, height);

            // Load sounds.
            killedSound = content.Load<SoundEffect>("Sounds/PlayerKilled");
            jumpSound = content.Load<SoundEffect>("Sounds/PlayerJump");
            fallSound = content.Load<SoundEffect>("Sounds/PlayerFall");

            spikeImpaleSound = content.Load<SoundEffect>("Sounds/PlayerKilledSpike");
            //spikeImpaleSound = jumpSound;
            waterDrownSound = content.Load<SoundEffect>("Sounds/PlayerKilledWater");
            fallImpactSound = content.Load<SoundEffect>("Sounds/PlayerKilledFall");
            //fallImpactSound = jumpSound;
        }
Esempio n. 21
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animated textures.
            idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Idle"), 0.1f, true);
            runAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Run"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Jump"), 0.1f, false);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false);
            crouchAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/crouch"), 0.1f, false);
            attackAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Attack"), 0.1f, false);

            attackAnimation.setWindowWidth(128);
            crouchAnimation.setWindowWidth(64);
            idleAnimation.setWindowWidth(64);
            runAnimation.setWindowWidth(64);
            jumpAnimation.setWindowWidth(64);
            dieAnimation.setWindowWidth(128);
            dieAnimation.setFrameTime(0.75F);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.8);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 22
0
        public void LoadContent()
        {
            string root = "Sprites/Player/";
            idleAnimation = new Animation(Level.Content.Load<Texture2D>(root + "Idle"), 0.1f, true);
            runAnimation = new Animation(Level.Content.Load<Texture2D>(root + "Run"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>(root + "Run"), 0.1f, false);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>(root + "Idle"), 0.1f, false);
            celebrateAnimation = new Animation(Level.Content.Load<Texture2D>(root + "Run"), 0.1f, false);

            powerUpSound = Level.Content.Load<SoundEffect>("Sounds/Powerup");

            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.8);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 23
0
        public virtual void Load(string xmlPath)
        {
            var element = XElement.Load(xmlPath);
            var xanimations = element.Elements();

            foreach (var animation in xanimations)
            {
// ReSharper disable PossibleNullReferenceException
                string name = animation.Element("Name").Value;

                int fps = int.Parse(animation.Element("FramesPerSecond").Value);
                string fileName = animation.Element("FileName").Value;
                bool looping = bool.Parse(animation.Element("Looping").Value);

                int frames = 0;
                var rects = new List<Rectangle>();
                foreach (XElement frame in animation.Descendants("Clips"))
                {
                    int x = int.Parse(frame.Element("x").Value);
                    int y = int.Parse(frame.Element("y").Value);
                    int w = int.Parse(frame.Element("w").Value);
                    int h = int.Parse(frame.Element("h").Value);

                    var rect = new Rectangle(x, y, w, h);
                    rects.Add(rect);
                    frames++;
                }
// ReSharper restore PossibleNullReferenceException
                var anim = new Animation(_content.Load<Texture2D>(fileName), rects, name)
                {
                    FramesPerSecond = fps,
                    Looping = looping
                };
                anim.Finish += AnimationFinish;

                Animations.Add(name, anim);
            }
        }
Esempio n. 24
0
 // Messy but it works
 public Animation(Animation copy)
 {
     Texture = copy.Texture;
     Color = copy.Color;
     Origin = copy.Origin;
     Rotation = copy.Rotation;
     Scale = copy.Scale;
     Effects = copy.Effects;
     Clips = copy.Clips;
     FrameIndex = 0;
     Finished = false;
     NumFrames = copy.NumFrames;
     Name = copy.Name;
     timeElapsed = 0;
     Looping = copy.Looping;
     timePerFrame = copy.timePerFrame;
     Finish = copy.Finish;
     FrameSize = copy.FrameSize;
     LoopingFor = copy.LoopingFor;
     BoundingBoxes = copy.BoundingBoxes;
 }
Esempio n. 25
0
        /// Loads a particular enemy sprite sheet and sounds.
        /// </summary>
        public override void LoadContent(string spriteSet)
        {
            debugTexture = new Texture2D(Level.Game.ScreenManager.GraphicsDevice, 1, 1);
            debugTexture.SetData(new Color[] { Color.White });

            // Load animations.
            base.LoadContent(spriteSet);
            fireAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/" + spriteSet + "/Fire"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/" + spriteSet + "/Jump"), 0.1f, true);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.4);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);

            dummyTexture = new Texture2D(Level.Game.ScreenManager.GraphicsDevice, 1, 1);
            dummyTexture.SetData(new Color[] { Color.White });

            fireSound = level.Content.Load<SoundEffect>("Sounds/smb_bowserfire");
            hitSound = level.Content.Load<SoundEffect>("Sounds/hitSound");
            bowserFallSound = level.Content.Load<SoundEffect>("Sounds/smb_bowserfalls");

            health = 100.0f;
        }
Esempio n. 26
0
        /// <summary>
        /// Loads the player sprite sheet and sounds.
        /// </summary>
        public void LoadContent()
        {
            // Load animated textures.
            idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/cop_idle"), 0.1f, true);
            runAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/cop_running"), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/cop_jump"), 0.1f, false);
            celebrateAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/Celebrate"), 0.1f, false);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/cop_die"), 0.1f, false);
            rollAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/cop_roll2"), 0.1f, false);
            grenadeAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Player/cop_grenade"), 0.1f, false);

            killedSound = Level.Content.Load<SoundEffect>("Sounds/killedSound");
            jumpSound = Level.Content.Load<SoundEffect>("Sounds/jumpSound");
            rollSound = Level.Content.Load<SoundEffect>("Sounds/rollSound");
            hitSound = Level.Content.Load<SoundEffect>("Sounds/hitSound");

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.8);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);

            m_handgun = new HandGun(level, position, this);
            m_shotgun = new Shotgun(level, position, this);
            m_knife = new Knife(level, position, this);
            m_bomb = new Grenade(level, position, this);

            weapon = m_handgun;

            font = level.Content.Load<SpriteFont>("Fonts/Hud");
        }
Esempio n. 27
0
 private void StateChanged(PlayerState newState)
 {
     if (PreviousAnimation != null)
         PreviousAnimation = CurrentAnimation;
         
     string key = newState.ToString();
     CurrentAnimation = new Animation(Animations[key]);
 }
Esempio n. 28
0
        public void LoadContent(string idle, string run, string jump, string death, string roll, string grenade)
        {
            // Load animated textures.
            idleAnimation = new Animation(Level.Content.Load<Texture2D>(idle), 0.1f, true);
            runAnimation = new Animation(Level.Content.Load<Texture2D>(run), 0.1f, true);
            jumpAnimation = new Animation(Level.Content.Load<Texture2D>(jump), 0.1f, false);
            dieAnimation = new Animation(Level.Content.Load<Texture2D>(death), 0.1f, false);
            rollAnimation = new Animation(Level.Content.Load<Texture2D>(roll), 0.1f, false);
            grenadeAnimation = new Animation(Level.Content.Load<Texture2D>(grenade), 0.1f, false);

            // Calculate bounds within texture size.
            int width = (int)(idleAnimation.FrameWidth * 0.4);
            int left = (idleAnimation.FrameWidth - width) / 2;
            int height = (int)(idleAnimation.FrameWidth * 0.8);
            int top = idleAnimation.FrameHeight - height;
            localBounds = new Rectangle(left, top, width, height);
        }
Esempio n. 29
0
 private void playAnimationForSprite(int i, Animation animation)
 {
     AnimationPlayer player = sprites[i];
     player.PlayAnimation(animation);
     sprites[i] = player;
 }
Esempio n. 30
0
        /// <summary>
        /// Load the texture assets and position the spawner.
        /// </summary>
        /// <param name="content">The content manager for loading assets,</param>
        private void initialise(ContentManager content)
        {
            //load textures
            this.activated = new Animation(content.Load<Texture2D>("Activatable/spawner_on"), 0.15f, true);
            this.deactivated = new Animation(content.Load<Texture2D>("Activatable/spawner_off"), 0.15f, false);
            this.spawn = new Animation(content.Load<Texture2D>("Activatable/spawner_spawn"), 0.12f, delegate
            {
                animation.PlayAnimation(activated);
            });

            SetSpawnState(isActive);
        }