rorlick

So i pulled the runtimes from git, and imported the spine-c and spine-sfml files into a new project to get it working before i put it into my main project. I get the same error if i try using the spineboy() or goblins() methods, where it gives me the error:

Thread 1: EXC_BAD_ACCESS(code = 1, address = 0x38)

on this line in SkeletonData.c:

Animation* SkeletonData_findAnimation (const SkeletonData* self, const char* animationName) {
int i;
for (i = 0; i < self->animationCount; ++i)
if (strcmp(self->animations[i]->name, animationName) == 0) return self->animations[i];
return 0;
}


called from here:


Atlas* atlas = Atlas_readAtlasFile("../data/goblins.atlas");
SkeletonJson* json = SkeletonJson_create(atlas);
json->scale = 2;
SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "../data/goblins.json");
Animation* walkAnimation = SkeletonData_findAnimation(skeletonData, "walk");
SkeletonJson_dispose(json);

SkeletonDrawable* drawable = new SkeletonDrawable(skeletonData);
drawable->timeScale = 1;

Skeleton* skeleton = drawable->skeleton;
skeleton->flipX = false;
skeleton->flipY = false;
Skeleton_setSkinByName(skeleton, "goblin");
Skeleton_setSlotsToSetupPose(skeleton);
// Skeleton_setAttachment(skeleton, "left hand item", "dagger");

skeleton->root->x = 320;
skeleton->root->y = 590;
Skeleton_updateWorldTransform(skeleton);

AnimationState_setAnimation(drawable->state, walkAnimation, true);


I believe that particular error is related to the pointer going out of scope, but what I posted above is all the Spine code the program is running through before it quits, so I'm really not sure how to approach this. I confirmed the json has the appropriate animation name and I believe it loads correctly, so I'm just really confused right now. Thanks for any help!

Robert
rorlick
  • Posts: 7

Nate

Probably SkeletonJson_readSkeletonDataFile is returning NULL. Check for this and print the error, eg:
if (!skeletonData) printf("Error: %s\n", json->error);
Most likely it can't find the file at "../data/goblins.json".
User avatar
Nate

Nate
  • Posts: 12029

rorlick

Nate wrote:Probably SkeletonJson_readSkeletonDataFile is returning NULL. Check for this and print the error, eg:
if (!skeletonData) printf("Error: %s\n", json->error);
Most likely it can't find the file at "../data/goblins.json".
Progress! It does throw the error:

Error: Unable to read skeleton file: goblins.json

So I tried moving it to the same folder and adjusted the call appropriately("goblins.json instead of "../data/goblins.json") and still no luck. The JSON itself is fine I'm sure and this may be an easy fix, but I'm stumped.


Robert
rorlick
  • Posts: 7

Nate

Figure out where you are running the executable from (what the working directory is) and then give a path to your JSON file relative to that.
User avatar
Nate

Nate
  • Posts: 12029

rorlick

Nate wrote:Figure out where you are running the executable from (what the working directory is) and then give a path to your JSON file relative to that.
Yup, that did it! This is my first time doing serious development on a mac, took me a while just to find the build path. Thanks for the help!

Robert
rorlick
  • Posts: 7


Return to Editor