int main (void) { Atlas* atlas = Atlas_readAtlasFile("data/spineboy.atlas"); printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y); printf("First page name: %s, size: %d, %d\n", atlas->pages->name, atlas->pages->width, atlas->pages->height); SkeletonJson* json = SkeletonJson_create(atlas); SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/spineboy.json"); if (!skeletonData) { printf("Error: %s\n", json->error); exit(0); } printf("Default skin name: %s\n", skeletonData->defaultSkin->name); Skeleton* skeleton = Skeleton_create(skeletonData); Animation* animation = SkeletonData_findAnimation(skeletonData, "walk"); if (!animation) { printf("Error: Animation not found: walk\n"); exit(0); } printf("Animation timelineCount: %d\n", animation->timelineCount); Skeleton_dispose(skeleton); SkeletonData_dispose(skeletonData); SkeletonJson_dispose(json); Atlas_dispose(atlas); return 0; }
CCSkeleton* CCSkeleton::create (const char* skeletonDataFile, Atlas* atlas, float scale) { SkeletonJson* json = SkeletonJson_create(atlas); json->scale = scale; SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); SkeletonJson_dispose(json); CCSkeleton* node = skeletonData ? create(skeletonData) : 0; node->ownsSkeleton = true; return node; }
CCSkeleton::CCSkeleton (const char* skeletonDataFile, Atlas* atlas, float scale) { initialize(); SkeletonJson* json = SkeletonJson_create(atlas); json->scale = scale; SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCAssert(skeletonData, json->error ? json->error : "Error reading skeleton data."); SkeletonJson_dispose(json); setSkeletonData(skeletonData, true); }
CCSkeleton::CCSkeleton (const char* skeletonDataFile, const char* atlasFile, float scale) { initialize(); atlas = Atlas_readAtlasFile(atlasFile); CCASSERT(atlas, "Error reading atlas file."); SkeletonJson* json = SkeletonJson_create(atlas); json->scale = scale; SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); CCASSERT(skeletonData, json->error ? json->error : "Error reading skeleton data file."); SkeletonJson_dispose(json); setSkeletonData(skeletonData, true); }
CCSkeleton* CCSkeleton::create (const char* skeletonDataFile, const char* atlasFile, float scale) { Atlas* atlas = Atlas_readAtlasFile(atlasFile); if (!atlas) return 0; SkeletonJson* json = SkeletonJson_create(atlas); json->scale = scale; SkeletonData* skeletonData = SkeletonJson_readSkeletonDataFile(json, skeletonDataFile); SkeletonJson_dispose(json); if (!skeletonData) { Atlas_dispose(atlas); return 0; } CCSkeleton* node = create(skeletonData); node->ownsSkeleton = true; node->atlas = atlas; return node; }
void ofxSkeleton::setup(string atlasPath, string jsonPath){ Bone_setYDown(true); atlas = Atlas_readAtlasFile(atlasPath.c_str()); SkeletonJson * json = SkeletonJson_create(atlas); skeletonData = SkeletonJson_readSkeletonDataFile(json, jsonPath.c_str()); SkeletonJson_dispose(json); skeleton = Skeleton_create(skeletonData); skeleton->flipX = false; skeleton->flipY = false; Skeleton_setToSetupPose(skeleton); stateData = AnimationStateData_create(skeletonData); state = AnimationState_create(stateData); }
int main (void) { Atlas* atlas = Atlas_readAtlasFile("data/spineboy.atlas"); printf("First region name: %s, x: %d, y: %d\n", atlas->regions->name, atlas->regions->x, atlas->regions->y); printf("First page name: %s, extraData: %d\n", atlas->pages->name, ((ExampleAtlasPage*)atlas->pages)->extraData); SkeletonJson* json = SkeletonJson_create(atlas); SkeletonData *skeletonData = SkeletonJson_readSkeletonDataFile(json, "data/spineboy-skeleton.json"); if (!skeletonData) printf("Error: %s\n", json->error); printf("Attachment extraData: %d\n", ((ExampleRegionAttachment*)skeletonData->defaultSkin->entries->attachment)->extraData); Skeleton* skeleton = Skeleton_create(skeletonData); printf("Skeleton extraData: %d\n", ((ExampleSkeleton*)skeleton)->extraData); Animation* animation = SkeletonJson_readAnimationFile(json, "data/spineboy-walk.json", skeletonData); if (!animation) printf("Error: %s\n", json->error); printf("Animation timelineCount: %d\n", animation->timelineCount); Skeleton_dispose(skeleton); SkeletonData_dispose(skeletonData); SkeletonJson_dispose(json); Atlas_dispose(atlas); return 0; }