I export a skeleton with spine, but the texture the artist use have large blank border. When I using texture packer to combine all the images into one, I use trim mode, which will compress all the border, and store in texture frame data.
When I load it into the spine actionscript runtime, It show very strange. I put the resource file and screenshot in the attachment.
My test code is just modify the starling example:
[Embed(source = "test.xml", mimeType = "application/octet-stream")]
static public const SpineboyAtlasXml:Class;
[Embed(source = "test.png")]
static public const SpineboyAtlasTexture:Class;
[Embed(source = "tes.json", mimeType = "application/octet-stream")]
static public const SpineboyJson:Class;
// ...
public function Game () {
// ...
skeleton = new SkeletonAnimation(skeletonData);
skeleton.setAnimationStateData(stateData);
skeleton.skeleton.skinName = "0002";
skeleton.skeleton.setToSetupPose();
skeleton.x = 320;
skeleton.y = 820;
skeleton.setAnimation("walk", true);
skeleton.addAnimation("hit", false, 3);
skeleton.addAnimation("walk", true);
addChild(skeleton);
Starling.juggler.add(skeleton);
}
If I using the No trim mode to process the images, and keep the blank border inside the texture, It will be OK. I find the starling AttachmentLoader code:
switch (type) {
case AttachmentType.region:
var regionAttachment:RegionAttachment = new RegionAttachment(name);
var texture:Texture = Cvar.rdFactory.CreateTexture(_prefix + name);
if (texture)
{
var frame:Rectangle = texture.frame;
texture = Texture.fromTexture(texture); // Discard frame.
regionAttachment.rendererObject = new SkeletonImage(texture);
regionAttachment.regionOffsetX = frame.x;
regionAttachment.regionOffsetY = frame.y;
regionAttachment.regionWidth = frame.width;
regionAttachment.regionHeight = frame.height;
regionAttachment.regionOriginalWidth = texture.width;
regionAttachment.regionOriginalHeight = texture.height;
return regionAttachment;
}
else
{
return null;
}
case AttachmentType.boundingbox:
return new BoundingBoxAttachment(name);
}
throw new Error("Unknown attachment type: " + type);
Which store the frame data into the RegionAttachment, and process them in function: RegionAttachment.updateOffset.
I view many other language runtime, the algorithm do the same thing. I want to know it there any bug in this function, or I miss something?