spPathConstraint* spPathConstraint_create (spPathConstraintData* data, const spSkeleton* skeleton) { int i; spPathConstraint *self = NEW(spPathConstraint); CONST_CAST(spPathConstraintData*, self->data) = data; self->bonesCount = data->bonesCount; CONST_CAST(spBone**, self->bones) = MALLOC(spBone*, self->bonesCount); for (i = 0; i < self->bonesCount; ++i) self->bones[i] = spSkeleton_findBone(skeleton, self->data->bones[i]->name); self->target = spSkeleton_findSlot(skeleton, self->data->target->name); self->position = data->position; self->spacing = data->spacing; self->rotateMix = data->rotateMix; self->translateMix = data->translateMix; self->spacesCount = 0; self->spaces = 0; self->positionsCount = 0; self->positions = 0; self->worldCount = 0; self->world = 0; self->curvesCount = 0; self->curves = 0; self->lengthsCount = 0; self->lengths = 0; return self; }
WIPAnimator::WIPAnimator(const char* atlas_path,const char* json_path,i32 w,i32 h):time_scale(1) { _out_buffer = WIPRenderTexture::create(w,h); _frame_ref = 0; spAtlas* atlas = spAtlas_createFromFile(atlas_path, 0); spSkeletonJson* json = spSkeletonJson_create(atlas); json->scale = 0.8f; spSkeletonData *skeletonData = spSkeletonJson_readSkeletonDataFile(json, json_path); if (!skeletonData) { printf("Error: %s\n", json->error); getchar(); exit(0); } //spAnimation* walkAnimation = spSkeletonData_findAnimation(skeletonData, "walk"); spSkeletonJson_dispose(json); spSkeletonBounds* bounds = spSkeletonBounds_create(); spAnimationStateData* stateData = spAnimationStateData_create(skeletonData); //spAnimationStateData_setMixByName(stateData, "walk", "jump", 0.2f); //spAnimationStateData_setMixByName(stateData, "jump", "run", 0.2f); //spAnimationStateData_setMixByName(stateData, "shoot", "walk", 0.2f); //drawable = new SkeletonDrawable(skeletonData,stateData); spBone_setYDown(true); skeleton = spSkeleton_create(skeletonData); state = spAnimationState_create(stateData); time_scale = 1; //spSkeleton* skeleton = drawable->skeleton; skeleton->flipX = false; skeleton->flipY = false; //spSkeleton_setSkinByName(skeleton, "goblin"); spSkeleton_setToSetupPose(skeleton); skeleton->x = 0; skeleton->y = 0; spSkeleton_updateWorldTransform(skeleton); spSlot* headSlot = spSkeleton_findSlot(skeleton, "head"); state->listener = callback; if (false) { spAnimationState_setAnimationByName(state, 0, "test", true); } else { spAnimationState_setAnimationByName(state, 0, "flying", true); /* spAnimationState_addAnimationByName(drawable->state, 0, "jump", false, 3); spAnimationState_addAnimationByName(drawable->state, 0, "run", true, 0); spAnimationState_addAnimationByName(drawable->state,0,"shoot",true,3); spAnimationState_addAnimationByName(drawable->state, 0, "walk", true,3); */ } //spAnimationState_setAnimation(drawable->state, 0, walkAnimation, false); //drawable->bounds = bounds; }
spSlot* SkeletonRenderer::findSlot (const std::string& slotName) const { return spSkeleton_findSlot(_skeleton, slotName.c_str()); }
spSlot* Skeleton::findSlot (const char* slotName) const { return spSkeleton_findSlot(skeleton, slotName); }