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.dllto your mgcb -
Create a text file with
.atlasextension, this is used to specify a list of target folders containing the pngs. One subfolder per line, currently absolute paths not supported, just usemyimagefolderormyimagefolder/myothersubfolder -
From the pipeline tool, add the
.atlasto your mgcb, and configure just like a regular texture. Build -
In your C# Monogame project add a reference to
Monogame.TextureAtlasand 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);