public void LoadContent() { //spriteBatch = new SpriteBatch(Game.GraphicsDevice); // Load animations. runAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Enemy/" + enemy), 0.1f, true); dieAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Enemy/die_" + enemy), 0.5f, false); idleAnimation = new Animation(Level.Content.Load<Texture2D>("Sprites/Enemy/" + enemy + "-idle"), .1f, true); sprite.PlayAnimation(runAnimation); // Calculate bounds within texture size. int width = (int)(runAnimation.FrameWidth * 0.35); int left = (runAnimation.FrameWidth - width) / 2; int height = (int)(runAnimation.FrameHeight * 0.8); int top = runAnimation.FrameHeight - height; localBounds = new Rectangle(0, 0, runAnimation.FrameWidth, runAnimation.FrameHeight/2); }
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> public void LoadContent(GameScreen screen) { // Load animated textures. //spriteBatch = new SpriteBatch(screen.ScreenManager.GraphicsDevice); idleAnimation = new Animation(screen.ScreenManager.Game.Content.Load<Texture2D>("Sprites/Bobo/idle"), 0.1f, true); runAnimation = new Animation(screen.ScreenManager.Game.Content.Load<Texture2D>("Sprites/Bobo/running"), 0.1f, true); jumpAnimation = new Animation(screen.ScreenManager.Game.Content.Load<Texture2D>("Sprites/Bobo/jumping"), 0.1f, false); dieAnimation = new Animation(screen.ScreenManager.Game.Content.Load<Texture2D>("Sprites/Bobo/dead"), 0.1f, false); fireAnimation = new Animation(screen.ScreenManager.Game.Content.Load<Texture2D>("Sprites/Bobo/firing"), 0.1f, false); // Calculate bounds within texture size. int width = (int)(idleAnimation.FrameWidth * 1); int left = (idleAnimation.FrameWidth - width) / 2; int height = (int)(idleAnimation.FrameWidth * 1); int top = idleAnimation.FrameHeight - height; localBounds = new Rectangle(left, top, width, height); // Load Fireballs foreach (Fireball f in mFireballs) f.loadContent(screen); }
/// <summary> /// Begins or continues playback of an animation. /// </summary> /// public void PlayAnimation() { this.animation = new Animation(); this.frameIndex = 0; this.time = 0.0f; }