- संपादित
[Starling AS3] Multiple Skins -> multiple Atlases ?
Hi guys,
I have one skeleton, multiples animations and multiples skins. All my assets can't fit in one atlas so I export them in 2 atlases from Texture Packer.
But know I don't know how to deal with my two atlases. So far I initialized my character like this :
var texture:Texture = Texture.fromBitmap(new SpineBoyAtlasTexture());
var xml:XML = XML(new SpineBoyAtlasXml());
var atlas:TextureAtlas = new TextureAtlas(texture, xml);
var json:SkeletonJson = new SkeletonJson(new StarlingAtlasAttachmentLoader(atlas));
var skeletonData:SkeletonData = json.readSkeletonData(new SpineBoyJson());
var stateData:AnimationStateData = new AnimationStateData(skeletonData);
_skeleton = new SkeletonAnimationSprite(skeletonData);
_skeleton.setAnimationStateData(stateData);
var spineCS:CitrusSprite = new CitrusSprite("test",{view:_skeleton});
add(spineCS);
So I have one SekeletonJson which uses an AtlasAttachementLoader which uses one Atlas. Then the SkeletonJson is used to initialize the SekeletonData.
So How can I set-up more than one Atlas ? It's not really clear in my head. I have read about AttachmentLoader but don't really understand how it can help me in that case. I'm pretty new on Spine so I'm a bit lost here.
Thanks
Relevant docs here:
http://esotericsoftware.com/spine-using ... mentloader
Take a look at StarlingAtlasAttachmentLoader. Line 24 has "atlas.getTexture(name)" to look up the region for a RegionAttachment. What you need to do is write your own, similar AttachmentLoader to look up the region in one atlas and if not found then look in another atlas (or maybe you have a better way of knowing which atlas contains an image, eg maybe by a prefix in the attachment name).
Thanks for the answer !
But I'm still lost here, like I said, I don't know how to use an AtlasAttachmentLoader. If I create an AtlasAttachmentLoader, to what object should I plug/set or whatever the AtlasAttachmentLoader ?
Thanks
EDIT :
I can set the Skeleton instance attachmentLoad but it means that I can set only one and only before instantiate the SkeletonData. So it not really helps if I have to re-create all that objects every time. Or is it possible de change the Skeleton instance attachmentLoader on the fly on it will be update on all objects that depends on the Skeleton ?
Hi,
Actually I'm already using an StarlingAttachmentLoader as you can see in the code in my first post. But what it seems to be important is to create Attachment using the newAttachment method. But this method will return an Attachment and then what I have to do with it ?
Thank you
Instead of using StarlingAttachmentLoader, use your own AttachmentLoader. Copy/paste StarlingAttachmentLoader and make it look in two atlases instead of just one.
Ok, it's clear now in my head !
Thank you