Hello,
I've been working on a simple platform engine using Spine for Starling.
Spine exporter and texture packer are great! but only produce LibGdx atlases.
You would need to repack the textures in the Starling format.
Why convert when you can code?
Here's a very quick and dirty way to "support" the libgdx format. It only reads xy and size.
It's just a proof of concept for Nate to see...Maybe an official implementation will follow? Plz Nate?
Note : Copy-paste broke some indentations
package utils
{
import flash.geom.Rectangle;
import flash.utils.ByteArray;
import flash.utils.Dictionary;
import starling.textures.Texture;
import starling.textures.TextureAtlas;
public class LibGdxAtlas extends TextureAtlas
{
private var name:String;
private var x:Number;
private var width:Number;
private var height:Number;
private var frameX:Number;
private var y:Number;
private var frameY:Number;
private var frameWidth:Number;
private var frameHeight:Number;
/** Create a texture atlas from a texture by parsing the regions from an XML file. */
public function LibGdxAtlas(texture:Texture, atlasFile:Class=null)
{
name = "";
x = 0;
y = 0;
width = 0;
height = 0;
frameX = 0;
frameY = 0;
frameWidth = 0;
frameHeight = 0;
super(texture);
parseAtlasGdx(atlasFile);
}
protected function parseAtlasGdx(atlasFile:Class):void
{
var scale:Number = texture.scale;
var txt:ByteArray = new atlasFile() as ByteArray;
var arr:Array = txt.toString().split(/\n/);
//trace(txt.toString());
for (var i:int = 5; i < arr.length; i++)
{
//trace(arr[i]);
var tmp:String = arr[i];
//search for a tab so we know its a new piece
if (tmp.search(" ") == -1)
{
//insert old one
if (name != "")
{
var region:Rectangle = new Rectangle(x, y, width, height);
var frame:Rectangle = frameWidth > 0 && frameHeight > 0 ?
new Rectangle(frameX, frameY, frameWidth, frameHeight) : null;
addRegion(name, region, frame);
}
//new region
name = tmp;
x = 0;
y = 0;
width = 0;
height = 0;
frameX = 0;
frameY = 0;
frameWidth = 0;
frameHeight = 0;
}
else
{
//what is this prop
if (tmp.search("xy:") != -1)
{
x = parseFloat(tmp.substr(tmp.search("xy:") + 3, tmp.search(",") - 5)) / scale;
y = parseFloat(tmp.substr(tmp.search(",") + 1, tmp.length)) / scale;
//trace("FOUND : "+x+" AND "+ y);
}
if (tmp.search("size:") != -1)
{
width = parseFloat(tmp.substr(tmp.search("size:") + 5, tmp.search(",") - 7)) / scale;
height = parseFloat(tmp.substr(tmp.search(",") + 1, tmp.length)) / scale;
//trace("FOUND : "+width+" AND "+ height);
}
}
}
}
}
}