Sprite Sheet Packer (at codeplex.com) is an excellent little utility for packing all sprites in a single large texture. It is very simple to use, simply add all the files that need to be packed and select destination file path and type. Transparency will be preserved for PNG images. For preventing issues when using mipmaps, you can add the padding around each image.
Final file should look something like this:
The tool will also generate a map file which contains location and size for each image. Two types are supported:
- TXT exporter: you must read it as a text file and manually parse it. Example file:
utop_IZ0036 = 0 0 100 100
utop_IZ0037 = 100 0 100 100
utop_IZ0038 = 0 100 100 100
utop_IZ0039 = 100 100 100 100
- XML exporter: you can add it as a content file to your main project (not your content library project) and use
Content.Load<Dictionary>for loading the file’s content.
<?xml version="1.0" encoding="utf-8" ?>
<Asset Type="System.Collections.Generic.Dictionary[System.String, Microsoft.Xna.Framework.Rectangle]">
<Item><Key>utop_IZ0036</Key><Value>0 0 100 100</Value></Item>
<Item><Key>utop_IZ0037</Key><Value>100 0 100 100</Value></Item>
<Item><Key>utop_IZ0038</Key><Value>0 100 100 100</Value></Item>
<Item><Key>utop_IZ0039</Key><Value>100 100 100 100</Value></Item>
Packing sprites into larger texture increases rendering speed (because texture does not need to be changed for each sprite). The tool is simple to use and easy to integrate into any content pipeline (GUI is merely a front-end for the console application).
Last updated byat .