- Đã chỉnh sửa
Exported animation not rendering in Cocos2dx
Hey guys,
I finally designed all the animations inside spine, and it's finally time to export and test in the cocos2dx engine. Exciting times!!
The problem is, the slots are not rendering. I have enabled the debug slots and debug skeleton, and I can only see the skeleton. I went into the rendering code, and it seems the spAttachment is NULL! I am using skins, and I am calling setSkin("skin_name"); right after creating the skeleton.
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
For now, I am using the spine example project to test my textures...
It might be worth mentioning that I couldn't use the TexturePacker within Spine, since it exported each skeleton into it's own texture atlas, and that is not exactly what I need. I need them all in the same texture (to batch draw them), so I used the famous TexturePacker2 to export as libGDX.
Any help appreciated!! :love:
FWIW, I did some more debugging, and realized that the engine looks for a default skin, which it seems to use as a fallback maybe? In any case, I opened the json file exported by spine, and changed one of the skin names to default, and now it renders properly ... However, the issue remains on why would adding a default skin work? Not to mention that when I call setSkin("OtherSkin"), I still get the "default" skin shown on screen.
Now, I am almost 100% certain it's an issue with the cocos2dx runtime implementation, which means it makes more sense to continue this thread in the GitHub issues section.
Best,
Maz
DO'H!!
Call setSlotsToSetupPose after setSkin. See here:
http://esotericsoftware.com/spine-using ... ging-skinsThe dagger tip issue is because the goblin.spine project you are using is old and has a bug. You can download Spine again and use the goblins project from there, or edit the JSON as you have done.
Aye, sorry that is a gotcha. Maybe setSkin should take a boolean "setSlotsToSetupPose". I think I'll do that, since this is such a common issue.
The Spine TexturePacker can pack all your images into a single atlas. You will need to run it separately from exporting your JSON (choose Texture Packer in the menu). See here:
https://github.com/libgdx/libgdx/wiki/Texture-packer
Thanks for the reply, Nate. I am sure a lot of developers will find the boolean addition helpful. I have to say though, it's also a lesson for me to actually read and understand an API before using it, by simply reading all the methods and classes.
Best,
Hi, I have a very similar problem with cocos2d-x 2.1.4, I can see only Bones and Slots debug as you can see in picture attached
https://www.dropbox.com/s/ghuptgw2c4docos/Immagine.png
and here my code:
skeletonNode = cocos2d::extension::CCSkeletonAnimation::createWithFile("animations/loading_mulele/skeleton.json","animations/loading_mulele/skeleton.atlas");
CC_SAFE_RETAIN(skeletonNode);
skeletonNode->setAnchorPoint(ccp(0,0));
skeletonNode->setPosition(ccp(250,0));
skeletonNode->setAnimation("hand_shaking",true,0);
skeletonNode->setVisible(true);
skeletonNode->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1),
CCFadeIn::create(1),
CCDelayTime::create(5),
NULL)));
skeletonNode->debugBones = true;
skeletonNode->debugSlots = true;
skeletonNode->update(0);
addChild(skeletonNode);
scheduleUpdate();
PLEASE: Help me!!
Daniele
Try skeletonNode->setToSetupPose()?
I haven't had a chance to add a boolean to setSkin, but it's on the Trello board.