Exemple #1
0
SkeletonDrawable::SkeletonDrawable (spSkeletonData* skeletonData, spAnimationStateData* stateData) :
				timeScale(1),
				vertexArray(new VertexArray(Quads, skeletonData->boneCount * 4)) {
	spBone_setYDown(true);

	skeleton = spSkeleton_create(skeletonData);
	state = spAnimationState_create(stateData);
}
Exemple #2
0
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;
}