Getting started with TexturePacker and MonoGame

This overview shows you how to create your first sprite sheet and import it into your MonoGame project.

These 6 steps will cost you only 5 minutes - but make your development much easier. Promised!

1.
Open TexturePacker, select MonoGame as framework.

TexturePacker: Select MonoGame as framework

2.
Add sprites ...

Drag & drop sprites
onto TexturePacker.


... or folders

TexturePacker adds
all sprites inside the folder
and updates the texture
when the content changes.

Add Sprites to TexturePacker

3.
Set output files
Make sure to set the output path of your data and texture file inside the Contents folder of your MonoGame project and the class file within your app's source tree.

Set the output path for your files

4.
Optional: Set Trim mode and Pivot Point
Crop removes transparency from sprites, allowing a better packing ratio.

TexturePacker allows you to set a Pivot Point and Trim your sprite

5.
Click Publish sprite sheet to write the sprite sheet to your MonoGame project.

TexturePacker: Click Publish sprite sheet

6.

Sprite Sheet Loader
Instantiate a new instance of the SpriteSheetLoader class.

var spriteSheetLoader = new SpriteSheetLoader(this.Content);
this.spriteSheet = spriteSheetLoader.Load("CapGuyDemo.png");

7.
Instantiate SpriteRender
in your LoadContent method

this.spriteBatch = new SpriteBatch(GraphicsDevice);
this.spriteRender = new SpriteRender(this.spriteBatch);

8.

And then in your Draw method render your frames like this using the class file to check file names at compile time:

this.spriteBatch.Begin();

this.spriteRender.Draw(
    this.spriteSheet.Sprite(
    TexturePackerMonoGameDefinitions.CapGuyDemo.Capguy_turn_0002),
    new Vector2(350, 530));

this.spriteBatch.End();

Do you want to read more?

Head over to our MonoGame tutorials section.

Do you have any feedback or questions?