public void PlayAnimation(Animation animation) { //if (Animation == animation) //{ // return; //} this.animation = animation; this.frameIndex = 0; this.time = 0.0f; }
public void PlayAnimation(Animation animation) { if (Animation == animation) { return; } this.animation = animation; this.frameIndex = 0; this.time = 0.0f; }
public void LoadContent() { string imageIdle = ""; string imageAttack = ""; float positionAdjustX = 0.0f; float positionAdjustY = 0.0f; int idleFrames = 1; int attackFrames = 1; switch (name) { case "hero": imageIdle = "HeroSprite/heroIdle_3"; imageAttack = "HeroSprite/attack1"; positionAdjustX = -130.0f; positionAdjustY = 20.0f; idleFrames = (int)frames.hero_idle; attackFrames = (int)frames.hero_att; break; case "support1": imageIdle = "SupportSprite/Support_Air1"; positionAdjustX = -10.0f; positionAdjustY = -130.0f; idleFrames = (int)frames.support1; break; } player = content.Load<Texture2D>(imageIdle); idleAnimation = new Animation(player, 0.5f, true, idleFrames); if (name == "hero") { attackAnimation = new Animation(content.Load<Texture2D>(imageAttack), 0.2f, false, attackFrames); } int positionX = (Level.windowWidth / 2) - (player.Width / 4); int positionY = (Level.windowHeight / 2) - (player.Height / 4); playerPosition = new Vector2((float)positionX + positionAdjustX, (float)positionY + positionAdjustY); spritePlayer.PlayAnimation(idleAnimation); }
public void LoadContent() { string imageIdle = ""; string imageAttack = ""; string imageDead = ""; float positionAdjustX = 0.0f; float positionAdjustY = 0.0f; switch (name) { case "snowman": imageIdle = "EnemySprite/EnemyIdle"; imageAttack = "EnemySprite/EnemyAttacked"; imageDead = "EnemySprite/EnemyDead"; positionAdjustX = 250.0f; positionAdjustY = -130.0f; idleFrames = 4; attackFrames = 3; deadFrames = 4; lifePoints = 100; break; case "shroom": imageIdle = "EnemySprite/Enemy2Idle"; imageAttack = "EnemySprite/Enemy2Attacked"; imageDead = "EnemySprite/Enemy2Dead"; positionAdjustX = 220.0f; positionAdjustY = -130.0f; idleFrames = 4; attackFrames = 1; deadFrames = 5; lifePoints = 250; break; } player = content.Load<Texture2D>(imageIdle); idleAnimation = new Animation(player, 0.1f, true, idleFrames); attackAnimation = new Animation(content.Load<Texture2D>(imageAttack), 0.1f, false, attackFrames); deadAnimation = new Animation(content.Load<Texture2D>(imageDead), 0.1f, false, deadFrames); int positionX = (Level.windowWidth / 2) - (player.Width / 4); int positionY = (Level.windowHeight / 2) - (player.Height / 4); playerPosition = new Vector2((float)positionX + positionAdjustX, (float)positionY + positionAdjustY); spritePlayer.PlayAnimation(idleAnimation); }