Nate yazdıIf your attachments have been defined in the Spine editor, you can implement your own AttachmentLoader:
http://esotericsoftware.com/spine-using ... mentloader
This allows you to look up regions however you want, eg in any number of atlases. Since it also controls the creation of RegionAttachments, you could even do lazy loading.
If you want to attach arbitrary images not defined in the editor, you can create a RegionAttachment programmatically, configure it with the appropriate region and attachment offset, and then use Slot#setAttachment(Attachment) instead of Skeleton#setAttachment(String,String).
http://esotericsoftware.com/spine-using ... ttachments
Hmm...not familiar with configuring RegionAttachment, and it's also better to lookup images in an atlas file.
Looking into the code, I don't wanna parse the atlas files for each new attachment (if not in the default atlas), and I don't wanna save a huge atlas file for each single skeleton. So I think we can probably have a central place to hold all shared common attachments.
Here is what i'm trying to do:
- create a skeleton template which contains all weapons/armors/etc., but it doesn't have any action.Let's call it skeletonTemplate;
- create the animation skeleton for the NPC, name it skeletonNpc;
now, if we wanna replace the weapon for the NPC, we can do this:
Attachment* pNewAttachment = skeletonTemplate->getAttachment("weapon", "sword");
Slot_setAttachment(skeletonNpc->findSlot("weapon"), pNewAttachment);
Any comment?