filterSekai

Hi.

I want to apply some skins into my skeleton in my objective c project, but i got an error in spSkin_addSkin.
Thread 1: EXC_BAD_ACCESS (code=1, address=0x8)
This is how I created my skeleton
const char *atlasStr = [atlas UTF8String];
spAtlas* myAtlas = spAtlas_createFromFile(atlasStr, 0);

const char *skeletonStr = [skeleton UTF8String];
spSkeletonJson* myJson = spSkeletonJson_create(myAtlas);
myJson->scale = 1;

spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(myJson, skeletonStr);
spSkin* skin = spSkin_create("mix-and-match");
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "face"));
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "base_head"));
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "base_body"));

spSkeleton* drawable = spSkeleton_create(skeletonData);

spSkeleton_setSkin(drawable, skin);
spSkeleton_setSlotsToSetupPose(drawable);

skeletonNode = [SkeletonAnimation skeletonWithData:skeletonData ownsSkeletonData:TRUE];
My assets are exported using spine 3.8.59, and I am using runtimes from branch 3.8. Any ideas? Thank you
filterSekai
  • Posts: 17

badlogic

Please post the full stack trace for the exception. My guess is that spSkeletonData_findSkin() returns NULL, which means the skin couldn't be found.
User avatar
badlogic

Mario
  • Posts: 1936

filterSekai

badlogic wrote:Please post the full stack trace for the exception. My guess is that spSkeletonData_findSkin() returns NULL, which means the skin couldn't be found.
After debug then I realized, there is something wrong in spSkin_addSkin function, in this line
entry = spSkin_getAttachments(other);
while (entry) {
spSkin_setAttachment(self, entry->slotIndex, entry->name, entry->attachment);
entry = entry->next;
}
while block is running for a while, entry per entry, then after the entry.name is face1, then the entry is NULL and crashed. This is my asset https://drive.google.com/open?id=1CSXknVpcQ2RL8FGi8HVIg9g0Dp6mbtdi Thank you!

---

filterSekai wrote:
badlogic wrote:Please post the full stack trace for the exception. My guess is that spSkeletonData_findSkin() returns NULL, which means the skin couldn't be found.
After debug then I realized, there is something wrong in spSkin_addSkin function, in this line
entry = spSkin_getAttachments(other);
while (entry) {
spSkin_setAttachment(self, entry->slotIndex, entry->name, entry->attachment);
entry = entry->next;
}
while block is running for a while, entry per entry, then after the entry.name is face1, then the entry is NULL and crashed. This is my asset https://drive.google.com/open?id=1CSXknVpcQ2RL8FGi8HVIg9g0Dp6mbtdi Thank you!
Hi @badlogic,

My fault. There are no "base_head" and "base_body" in my json skeleton skin. But I think I still have a question, how to apply spSkin object into our skeletonData?
spSkin* skin = spSkin_create("default");
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "face"));
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "bottom_short"));
I created custom skin and I read in spine-runtimes/main.cpp at 3.8 but still have no clue how to add into our skeletonData. Tried to look at the example code, but found nothing. Thank you.
filterSekai
  • Posts: 17

Nate

You use the skin by setting it on the skeleton, this line:
spine-runtimes/main.cpp at 3.8
spSkeleton_setSkin(skeleton, skin);
Note you often want to call Skeleton setSlotsToSetupPose after changing the skin (see Skeleton setSkin).

You don't need to add it to the SkeletonData (though you could).
User avatar
Nate

Nate
  • Posts: 9161

filterSekai

Nate wrote:You use the skin by setting it on the skeleton, this line:
spine-runtimes/main.cpp at 3.8
spSkeleton_setSkin(skeleton, skin);
Note you often want to call Skeleton setSlotsToSetupPose after changing the skin (see Skeleton setSkin).

You don't need to add it to the SkeletonData (though you could).
I created drawable as my skeleton
spSkeletonData* skeletonData = spSkeletonJson_readSkeletonDataFile(myJson, skeletonStr);
spSkin* skin = spSkin_create("default");
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "face"));
spSkin_addSkin(skin, spSkeletonData_findSkin(skeletonData, "bottom_short"));

spSkeleton* drawable = spSkeleton_create(skeletonData);
spSkeleton_setSkin(drawable, skin);
spSkeleton_setSlotsToSetupPose(drawable);


But how can I create SkeletonAnimation with spSkeleton object? I need that for my CCNode properties (as the example said).
@interface CharPreviewNode : CCNode {
SkeletonAnimation* skeletonNode;
}
Thank you, Nate!
filterSekai
  • Posts: 17

badlogic

You don't need to create a new spSkeleton. Just get the spSkeleton from the SkeletonAnimation. The property is called skeleton, see spine-runtimes/SkeletonRenderer.h at 3.8
User avatar
badlogic

Mario
  • Posts: 1936

filterSekai

badlogic wrote:You don't need to create a new spSkeleton. Just get the spSkeleton from the SkeletonAnimation. The property is called skeleton, see spine-runtimes/SkeletonRenderer.h at 3.8
I called skeleton from my skeletonNode, but the instance variable skeleton is protected (readonly).
spSkeleton_setSkin(skeletonNode->_skeleton, skin);
spSkeleton_setSlotsToSetupPose(skeletonNode->_skeleton);
Any idea?
filterSekai
  • Posts: 17

badlogic

It's a property, so you'll have to use skeletonNode.skeleton.
User avatar
badlogic

Mario
  • Posts: 1936


Return to Runtimes