private void LoadContent() { ground = new Animation(level.Content.Load<Texture2D>("InfoBox/Ground"), 0.1f, true, true); pick = new Animation(level.Content.Load<Texture2D>("InfoBox/Pick"), 0.1f, true, true); sprite.PlayAnimation(ground); }
/// <summary> /// Loads a particular enemy sprite sheet and sounds. /// </summary> public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Enemy/" + spriteSet + "/"; runAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + Level.LevelIndex.ToString() + "_Run"), 0.12f, true, true); idleAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + Level.LevelIndex.ToString() + "_Idle"), 0.1f, true, true); dieAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + Level.LevelIndex.ToString() + "_Die"), 0.1f, false, true); sprite.PlayAnimation(idleAnimation); if (IsPollutant) BubbleOverlay = Level.Content.Load<Texture2D>(spriteSet + Level.LevelIndex.ToString() + "_BubOverlay"); radius = (int)(idleAnimation.FrameWidth / 2 * 0.75); }
protected void LoadContent() { PointValue = 10 * (PowerIndex + 1) * (playPick ? 1 : 0); string powerUp = this.ToString().Remove(0, "Gombli.".Length); string path = "PowerUp/" + powerUp + "/"; groundAnimation = new Animation(Level.Content.Load<Texture2D>(path + "Ground"), 0.2f, true, true); dropAnimation = new Animation(Level.Content.Load<Texture2D>(path + "Drop"), 0.1f, false, true); dieAnimation = new Animation(Level.Content.Load<Texture2D>(path + "Die"), 0.1f, false, true); pickAnimation = new Animation(Level.Content.Load<Texture2D>("PowerUp/Pick"), 0.1f, false, true); activeAnimation = new Animation(Level.Content.Load<Texture2D>(path + "Active"), 0.1f, PowerIndex == 3 ? true : false, true); hit = Level.Content.Load<SoundEffect>(path + "Hit"); pick = Level.Content.Load<SoundEffect>("PowerUp/power pick"); radius = (int)(groundAnimation.FrameWidth / 2 * 0.67f); sprite.PlayAnimation(groundAnimation); if (Position == Level.InvalidPositionVector) Picked(); }
/// <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> private void LoadContent() { // Load animated textures. idleAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Idle"), 0.1f, false); runAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Run"), 0.1f, true); jumpAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Jump"), 0.1f, false); celebrateAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Celebrate"), 0.18f, true); dieAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Die"), 0.1f, false); throwAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Throw"), 0.08f, false); climbAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Climb"), 0.2f, true); swimAnimation = new Animation(Level.Content.Load<Texture2D>("Gombli/Swim"), 0.2f, true); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.28); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.82); 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>("Gombli/PlayerJump"); //fallSound = Level.Content.Load<SoundEffect>("Sounds/PlayerFall"); }
/// <summary> /// Loads a particular animal sprite sheet and sounds. /// </summary> public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Animal/" + spriteSet + "/"; if (!isLazy) runAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + Level.LevelIndex.ToString() + "_Run"), 0.1f, true); idleAnimation = new Animation(Level.Content.Load<Texture2D>(spriteSet + Level.LevelIndex.ToString() + "_Idle"), 0.5f, true); sprite.PlayAnimation(idleAnimation); Vector2 fraction; if (isLazy) fraction = new Vector2(0.59f, 0.92f); else if (isFloating) fraction = new Vector2(); else fraction = new Vector2(0.25f, 0.65f); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * fraction.X); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * fraction.Y); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }