public void PlayAnimation(Animation animation) { if (Animation == animation) { return; } this.animation = animation; this.frameIndex = 0; this.time = 0.0f; }
public void LoadContent() { TrunksIdle = content.Load<Texture2D>("Sprites/trunks"); TrunksAttack = content.Load<Texture2D>("Sprites/trunks attack"); idleAnimationTrunks = new Animation(TrunksIdle, 0.1f, true, 6); attackAnimationTrunks = new Animation(TrunksAttack, 0.1f, false, 5); spritePlayerTrunks.PlayAnimation(idleAnimationTrunks); GotenIdle = content.Load<Texture2D>("Sprites/Goten idle"); GotenAttack = content.Load<Texture2D>("Sprites/Goten attack"); idleAnimationGoten = new Animation(GotenIdle, 0.1f, true, 5); attackAnimationGoten = new Animation(GotenAttack, 0.1f, false, 6); spritePlayerGoten.PlayAnimation(idleAnimationGoten); OwlFlying = content.Load<Texture2D>("Sprites/Owl flying"); OwlHit = content.Load<Texture2D>("Sprites/Owl hit"); animationOwlFlying = new Animation(OwlFlying, 0.1f, true, 6); animationOwlHit = new Animation(OwlHit, 0.1f, true, 6); spritePlayerOwl.PlayAnimation(animationOwlFlying); GotenExplosion = content.Load<Texture2D>("Sprites/Goten explosion"); animationGotenExplosion = new Animation(GotenExplosion, 0.1f, true, 6); spritePlayerGotenExplosion.PlayAnimation(animationGotenExplosion); if (trunks == 1) { positionX = (Level.windowWidth / 2) - (TrunksIdle.Width / 4) + 280; positionY = (Level.windowHeight / 2) - (TrunksIdle.Height / 4) + 60; TrunksPosition = new Vector2((float)positionX, (float)positionY); } if (goten == 1) { positionX = (Level.windowWidth / 2) - (GotenIdle.Width / 4) + 55; positionY = (Level.windowHeight / 2) - (GotenIdle.Height / 4) + 60; GotenPosition = new Vector2((float)positionX, (float)positionY); goten = 0; } if (owl == 1) { positionX = (Level.windowWidth / 2) + 10; positionY = (Level.windowHeight / 2) - 20; OwlPosition = new Vector2((float)positionX, (float)positionY); } }