/// <summary> /// Loads the object sprite sheet. /// </summary> public void LoadContent(String spriteSet) { // Load animated textures. idleAnimation = new Animation(Game.Content.Load<Texture2D>(spriteSet+"Idle"), 0.1f, true); hoverAnimation = new Animation(Game.Content.Load<Texture2D>(spriteSet + "Run"), 0.1f, true); clickAnimation = new Animation(Game.Content.Load<Texture2D>(spriteSet + "Die"), 0.1f, true); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.4); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.8); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
/// <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 a particular enemy sprite sheet and sounds. /// </summary> public void LoadContent(string spriteSet) { // Load animations. spriteSet = "Sprites/" + spriteSet + "/"; runAnimation = new Animation(Game.Content.Load<Texture2D>(spriteSet + "Run"), 0.1f, true); idleAnimation = new Animation(Game.Content.Load<Texture2D>(spriteSet + "Idle"), 0.15f, true); sprite.PlayAnimation(idleAnimation); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.35); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.7); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }
/// <summary> /// Loads the player sprite sheet and sounds. /// </summary> public void LoadContent() { // Load animated textures. idleAnimation = new Animation(Game.Content.Load<Texture2D>("Sprites/Player/Idle"), 0.1f, true); runAnimation = new Animation(Game.Content.Load<Texture2D>("Sprites/Player/Run"), 0.1f, true); celebrateAnimation = new Animation(Game.Content.Load<Texture2D>("Sprites/Player/Celebrate"), 0.1f, false); dieAnimation = new Animation(Game.Content.Load<Texture2D>("Sprites/Player/Die"), 0.1f, false); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 0.4); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 0.8); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); }