The Sprite class in MonoGame.Extended is one of the simplest. It's a mutable data structure for holding a single instance of a sprite in your game. Typically the sprite will refer to a TextureRegion2D on a TextureAtlas. It can also use a Texture2D for simplicity.

The class looks something like this (with the implementation removed):

public class Sprite
    public Sprite(TextureRegion2D textureRegion) { ... }
    public Sprite(Texture2D texture) { ... }

    public TextureRegion2D TextureRegion { get; set; }
    public Color Color { get; set; }
    public bool IsVisible { get; set; }
    public Vector2 Position { get; set; }
    public Vector2 Scale { get; set; }
    public float Rotation { get; set; }
    public Vector2 Origin { get; set; }
    public Vector2 OriginNormalized { get; set;}
    public SpriteEffects Effect { get; set; }
    public object Tag { get; set; }

    public Rectangle GetBoundingRectangle() { ... }
    public Vector2[] GetCorners() { ... }

To draw the sprite, MonoGame.Extended provides a SpriteBatch extension method.


Storing sprite data in a class like this has the immediate benefit that it makes rendering a collection of sprites significantly easier.

foreach(var sprite in spriteList)

Of course in the real world, game objects would typically be more than just a sprite. A common use would be to wrap it inside a game object like this hypothetical scenario. There are many other ways to use sprites.

public class Player
    private Sprite _sprite;

    public Vector2 Position 
        get { return _sprite.Position; }
        set { _sprite.Position = value; }

    public void Draw(SpriteBatch spriteBatch)

The Sprite class in MonoGame.Extended handles origins in an intuitive way. The Origin property is in pixels, just like the origin when using the SpriteBatch.Draw method directly. An added OriginNormalized property let's you set the origin without needing to know the exact size of the texture region. Setting it to (0.5, 0.5) puts the origin in the center and (1.0, 1.0) is the bottom right corner.

By default the origin will be in the center and later changing the texture region of the sprite will preserve the normalized origin if the new region is a different size.

For example, if the sprites texture region is 50 x 50 pixels, the Origin will default to (25, 25). If the TextureRegion is later changed to a 100 x 100 pixel region, the Origin will become (50, 50) to keep it in the center.

The Sprite class was released in MonoGame.Extended v0.2 and should provide a solid base for future improvements to the library.