Monogame — Animated Sprite [patched]
public void Update(GameTime gameTime) { if (!IsPlaying) return;
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); // Load a spritesheet: each frame is 64x64, 8 frames total (8 columns, 1 row) _spritesheet = Content.Load<Texture2D>("player_run"); _animatedSprite = new AnimatedSprite(_spritesheet, 64, 64, 12.0, true); } monogame animated sprite
public void Play() => IsPlaying = true; public void Pause() => IsPlaying = false; public void Stop() { IsPlaying = false; _currentFrame = 0; _elapsedTime = 0; } public void Restart() { _currentFrame = 0; _elapsedTime = 0; IsPlaying = true; } } using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; public class Game1 : Game { private GraphicsDeviceManager _graphics; private SpriteBatch _spriteBatch; private AnimatedSprite _animatedSprite; private Texture2D _spritesheet; public void Update(GameTime gameTime) { if (