This monogame pipeline extension packs png files into a texture atlas. The packing code was taken from the nuclex framework http://nuclexframework.codeplex.com/
-
Using the content pipeline tool, add
Monogame.TextureAtlas.PipelineExtension.dll
to your mgcb -
Create a text file with
.atlas
extension, this is used to specify a list of target folders containing the pngs. One subfolder per line, currently absolute paths not supported, just usemyimagefolder
ormyimagefolder/myothersubfolder
-
From the pipeline tool, add the
.atlas
to your mgcb, and configure just like a regular texture. Build -
In your C# Monogame project add a reference to
Monogame.TextureAtlas
and load the atlas using theContentManager
:
var myAtlas = Content.Load<TextureAtlas>("myatlas");
//then retrieves the sprites
this.Sprites = myAtlas.Sprites
- Then using a SpriteBatch extension, draw a sprite:
SpriteBatch.Draw(Sprites[0], new Vector2(0, 0), Color.White);