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; }
public void LoadContent() { // Load animated textures. idleAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Player/PlayerIdle"), 0.1f, true); runAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Player/PlayerIdle"), 0.1f, true);//new Animation(map.Content.Load<Texture2D>("Sprites/Player/Run"), 0.1f, true); shootAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Player/PlayerShoot"), 0.2f, false);// new Animation(map.Content.Load<Texture2D>("Sprites/Player/Shoot"), 0.1f, false); dieAnimation = new Animation(game.Content.Load<Texture2D>("Sprites/Player/PlayerIdle"), 0.1f, true);//new Animation(map.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false);aw gunShot1 = game.Content.Load<SoundEffect>("Sounds/GunShot1"); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.8);// (int)(idleAnimation.FrameWidth * 0.4); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.8); int top = (idleAnimation.FrameHeight - height) / 2; localBounds = new Rectangle(left, top, width, height); // Load sounds. //killedSound = map.Content.Load<SoundEffect>("Sounds/PlayerKilled"); //shootSound = map.Content.Load<SoundEffect>("Sounds/PlayerShoot"); }
public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Sprites/" + spriteSet + "/"; idleAnimation = new Animation(game.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.15f, true); runAnimation = new Animation(game.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.1f, true); attackAnimation = new Animation(game.Content.Load<Texture2D>(spriteSet + "ZombieAttack"), 0.3f, false); dieAnimation = new Animation(game.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.15f, true); sprite.PlayAnimation(idleAnimation); //whiteBox = new Texture2D(graphicsDevice,1,1); //whiteRectangle.SetData(new[] { Color.White }); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.8); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.8); int top = (idleAnimation.FrameHeight - height) / 2; localBounds = new Rectangle(left, top, width, height); //firstTime = true; //direction = (float)Math.Atan2(game.player.Position.Y - Position.Y, game.player.Position.X - Position.X); //velocity = new Vector2((float)Math.Cos((double)direction), (float)Math.Sin((double)direction)); }
public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Sprites/" + spriteSet + "/"; idleAnimation = new Animation(Map.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.15f, true); runAnimation = new Animation(Map.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.1f, true); attackAnimation = new Animation(Map.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.15f, false); dieAnimation = new Animation(Map.Content.Load<Texture2D>(spriteSet + "ZombieIdle"), 0.15f, true); sprite.PlayAnimation(idleAnimation); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.8); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.8); int top = (idleAnimation.FrameHeight - height) / 2; localBounds = new Rectangle(left, top, width, height); }
public void LoadContent() { fly = new Animation(game.Content.Load<Texture2D>("Sprites/Projectiles/Default"), 0.1f, true); sprite.PlayAnimation(fly); int width = (int)(fly.FrameWidth * 0.35); int left = (fly.FrameWidth - width) / 2; int height = (int)(fly.FrameWidth * 0.2); int top = (fly.FrameHeight - height) / 2; localBounds = new Rectangle(left, top, width, height); }