蠻簡單好用的 不過因為我都是要倒給 Starling 的 TextureAltas 用的 所以稍微改一下他的原始碼
在 \sspack\Exporters\TxtMapExporter.cs 檔
public string MapExtension
{
get { return "xml"; }
}
public void Save(string filename, Dictionary<string, Rectangle> map)
{
// copy the files list and sort alphabetically
string[] keys = new string[map.Count];
map.Keys.CopyTo(keys, 0);
List<string> outputFiles = new List<string>(keys);
outputFiles.Sort();
using (StreamWriter writer = new StreamWriter(filename))
{
writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
writer.WriteLine("<TextureAtlas imagePath=\"" + Path.GetFileNameWithoutExtension(filename) + ".png\">");
foreach (var image in outputFiles) {
// get the destination rectangle
Rectangle destination = map[image];
// write out the destination rectangle for this bitmap
writer.WriteLine(string.Format(
" <SubTexture name=\"{0}\" x=\"{1}\" y=\"{2}\" width=\"{3}\" height=\"{4}\" />",
Path.GetFileNameWithoutExtension(image),
destination.X,
destination.Y,
destination.Width,
destination.Height));
}
writer.WriteLine("</TextureAtlas>");
}
}
有改的都標記出來了, 再重新編譯產出 sspack.exe 檔覆蓋掉原本的即可, 產出 XML 的看起來就會像是
<?xml version="1.0" encoding="UTF-8"?> <TextureAtlas imagePath="AllTexture.png"> <SubTexture name="apple" x="1284" y="221" width="299" height="35" /> <SubTexture name="arrow" x="1584" y="221" width="20" height="11" /> <SubTexture name="arrow_left" x="1140" y="975" width="23" height="29" /> <SubTexture name="arrow_right" x="1939" y="197" width="23" height="29" /> </TextureAtlas>這樣就可以直接把產出檔案 XML & PNG 餵給 Starling Framework 的 TextureAtlas 用囉~
如果沒錢買 TexturePacker 可以考慮試試看這個免費的軟體~
沒有留言:
張貼留言