private void LoadContent() { // Load images. Texture2D chargeTexture = game.Content.Load<Texture2D>("Weapons/chargeLaser"); Texture2D fullPowerTexture = game.Content.Load<Texture2D>("Weapons/chargeLaserFullPowerLoop"); Texture2D halfPowerTexture = game.Content.Load<Texture2D>("Weapons/chargeLaserHalfPowerLoop"); Texture2D deactivateTexture = game.Content.Load<Texture2D>("Weapons/deactivateCharge"); // Allocate new animations. chargeAnimation = new Animation(chargeTexture, Vector2.Zero, 64, 64, 20, 40, Color.White, 0.7f, false); fullPowerAnimation = new Animation(fullPowerTexture, Vector2.Zero, 64, 64, 4, 100, Color.White, 0.7f, true); halfPowerAnimation = new Animation(halfPowerTexture, Vector2.Zero, 54, 54, 4, 100, Color.White, 0.6f, true); deactivatingAnimation = new Animation(deactivateTexture, Vector2.Zero, 64, 64, 10, 10, Color.White, 0.7f, false); currentAnimation = chargeAnimation; }
public void SetChargeAnimation(Animation animation) { // If this animation is already running, do not restart it. if (currentAnimation == animation) return; // Start the new animation. currentAnimation = animation; currentAnimation.currentFrame = 0; currentAnimation.elapsedTime = 0.0f; }
/// <summary> /// Changes the sprite's animation to a new strip. /// </summary> /// <param name="newAnimation"> The new animation the sprite should have.</param> public virtual void SetAnimation(Animation newAnimation) { currentAnimation.isActive = false; currentAnimation = newAnimation; currentAnimation.isActive = true; }