// draw with sprite effect public static void DrawAnimation(this SpriteBatch spriteBatch, Animation animation, Vector2 position, float angle, SpriteEffects effect) { Point tile = animation.GetTile(animation.CurrentFrame); Rectangle source = new Rectangle(tile.X * animation.TileWidth, tile.Y * animation.TileHeight, animation.TileWidth, animation.TileHeight); Rectangle dest = new Rectangle(Round(position.X), Round(position.Y), animation.TileWidth, animation.TileHeight); spriteBatch.Draw(animation.Texture, dest, source, Color.White, angle, new Vector2(animation.TileWidth / 2, animation.TileHeight / 2), effect, 0); }
public static void DrawAnimation(this SpriteBatch spriteBatch, Animation animation) { DrawAnimation(spriteBatch, animation, Vector2.Zero, 0); }
//draw with angle and position public static void DrawAnimation(this SpriteBatch spriteBatch, Animation animation, Vector2 position, float angle) { DrawAnimation(spriteBatch, animation, position, angle, SpriteEffects.None); }
public void Init(ContentManager content) { Position = Vector2.Zero; RelativeSize = 1f; MoveSpeed = 0.2f; isMoving = false; Direction = DIRECTION.RIGHT; PacmanAnimation = new Animation(content.Load<Texture2D>("Graphics/pacamari"), 16, 16, 200); }