Simple Sprites & bone-like Transformations for MonoGame projects.
This mini-lib implements basic sprite class with transformations, that also support hierarchy and bone-like transformation inheritance.
In simple words, this provide the very basics needed to create bone-based 2d animations.
To see a live example, open and execute the solution in this repo.
To install the lib you can use NuGet:
Install-Package MonoGame.Sprites
Or you can manually copy the source files from MonoSprites/Source/
into your project.
This lib contains 4 main classes you should know:
Provide the basic API and functionality of any renderable entity. If you want to create your own custom sprites, inherit from it.
An entity that doesn't have any graphic representation of its own, but hold transformations to inherit to its children. Containers are good method to group together multiple sprites. For example, you can use it to scale or move a group of renderables evenly.
A simple renderable image with transformation and optional children.
A set of transformation properties, such as position, scale, rotation, zindex, color, etc..
Transformations class also implements the functionality to inherit transformations from parent to child instances. Normally you don't need to use this class directly, as it is used internally.
To create a new sprite:
MonoSprites.Sprite sprite = new MonoSprites.Sprite(Content.Load<Texture2D>("sprite_texture"));
And to draw it:
spriteBatch.Begin(SpriteSortMode.FrontToBack);
sprite.Draw(spriteBatch);
spriteBatch.End();
To create a container and use it:
MonoSprites.Container container = new MonoSprites.Container();
MonoSprites.Sprite sprite = new MonoSprites.Sprite(Content.Load<Texture2D>("sprite_texture"), parent: container);
// or: container.AddChild(Sprite);
Now every transformation you apply on the container will be inherited to the child sprite.
For more info you can check out the code (with focus on the Renderable and Sprite public API), or read the automatically generated doc file in MonoSprites/Help/
.
MonoGame-Sprites is distributed with the permissive MIT License. For more info, check out the LICENSE
file in this repo.