Hi Nate,
I don't know if you're still reading this post.. I made some progress on this - some more feedback is always appreciated =]
I made this small change to allow skeletons to load with partial atlases - 'git diff' output:
diff
---
git a/spine-c/src/spine/SkeletonJson.c b/spine-c/src/spine/SkeletonJson.c
index 242b74d..2a47ee4 100644
---
a/spine-c/src/spine/SkeletonJson.c
+++ b/spine-c/src/spine/SkeletonJson.c
@@ -351,11 +351,12 @@ SkeletonData* SkeletonJson_readSkeletonData (SkeletonJson* self, const char* jso
Attachment* attachment = AttachmentLoader_newAttachment(self->attachmentLoader, type, attachmentName);
if (!attachment) {
- if (self->attachmentLoader->error1) {
- SkeletonData_dispose(skeletonData);
- _SkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2);
- return 0;
- }
+// NOTE: sheado - removed to allow partial atlas support:
+// if (self->attachmentLoader->error1) {
+// SkeletonData_dispose(skeletonData);
+// _SkeletonJson_setError(self, root, self->attachmentLoader->error1, self->attachmentLoader->error2);
+// return 0;
+// }
continue;
}
Being unfamiliar with the run-time code, I don't know if this could cause a bug elsewhere though. But it does allow me to do the following in cocos2d-x:
// load a character with a skeleton and a specific skin's atlas
atlas = Atlas_readAtlasFile("bird_orange.atlas");
skeletonJson = SkeletonJson_create( atlas );
skeletonData = SkeletonJson_readSkeletonDataFile(skeletonJson, "skeleton.json");
animationStateData = AnimationStateData_create( skeletonData );
skeletonNode = CCSkeleton::create(skeletonData, animationStateData );
skeletonNode->setSkin( "bird_orange" );
skeletonNode->setSlotsToBindPose();
skeletonNode->setAnimation("animation_test_0", true);
skeletonNode->timeScale = 0.8f;
skeletonNode->setPosition(ccp(windowSize.width / 3 * 2, parentNode->getContentSize().height/2 + i*5));
parentNode->addChild(skeletonNode);
// load another cskeleton with a different skin atlas
atlas = Atlas_readAtlasFile("bird_red.atlas");
skeletonJson = SkeletonJson_create( atlas );
skeletonData = SkeletonJson_readSkeletonDataFile(skeletonJson, "skeleton.json");
animationStateData = AnimationStateData_create( skeletonData );
skeletonNode = CCSkeleton::create(skeletonData, animationStateData );
skeletonNode->setSkin( "bird_red" );
skeletonNode->setSlotsToBindPose();
skeletonNode->setAnimation("animation_test_0", true);
skeletonNode->timeScale = 0.8f;
skeletonNode->setPosition(ccp(windowSize.width / 3, parentNode->getContentSize().height/2 - 20 + i*5));
parentNode->addChild(skeletonNode);
In the code above, skeleton.json has skins bird_red and bird_orange. In the first block of code I use bird_orage.atlas which only has the bird_orange skin graphics. In the second block, I do the same but with a different atlas for a different skin.
The main disadvantage is that I have to keep reloading skeleton.json each time I need to load a character, but that seems to be ok so far. One unexpected advantage is that I got a 7fps boost (testing on an old Droid) with this approach.
Again, thanks for reading this far =]