Is there any sample code that demonstrates how to create skeletal animations using BoneNode and SkeletonNode with a .csb file in c++? Skeletal animations were just added to Cocos Studio 2.3.2. and Cocos2d-x 3.7.1 is supposed to support it. I just don’t know how to do it.
+1 definitely need such examples of code.
No one has been able to figure this out yet?
Here is some sample code.
Yep. Do you have any question about it?
No I figured it out after I looked at the sample code. Thanks again.
I finally made it work like this:
auto node = mLayerGame->getChildByName("PlayerSkeleton"); cocostudio::timeline::ActionTimeline* action = CSLoader::createTimeline("PlayerSkeleton.csb"); node->runAction(action); action->gotoFrameAndPlay(0);
Still have a pair of doubts, but at least I can move on!
What is the difference between Armature and ActionTimeline? I thought Armature was for bone-based animations, and ActionTimeline just animating a generic cocos scene.
Isn’t any way to get it all from the scene? I couldn’t load the ActionTimeline even though it is the “same” as the node to which the action is applied.
But this is ActionTimeline, not Armature, so no bones…? I was looking at this class:
But I can’t make it work on my project. As my project is C++ and I created the skeletal animation with Cocos Studio, I was looking for an example of just seeking the skeleton node inside the scene and use it, but there aren’t examples like this. The closest one is this:
// load from binary ArmatureDataManager::getInstance()->addArmatureFileInfo(m_binaryFilesNames); m_armature = Armature::create(m_armatureNames); m_armature->getAnimation()->playWithIndex(0); <- CRASH (BAD_ACCESS) m_armature->setScale(1.0f); m_armature->setPosition(VisibleRect::center().x, VisibleRect::center().y); addChild(m_armature);
Making the changes I need for my project (such as substituting the
m_armatureNames variable with the name of my csb file), it crashes when I try to do anything with the animation.
If I drag and drop the skeletal animation inside a scene in Cocos Studio, it spawns as a node and seems to work, but then at code I look for it by name and cast it to
cocostudio::Armature and use like this:
auto skeleton = scene->getChildByName<cocostudio::Armature*>("PlayerSkeleton"); skeleton->getAnimation()->playWithIndex(0); <- CRASH (BAD_ACCESS)
What I am supposed to do?
Anyone, please? @zhangxm
I still don’t get which is the difference between Armature and ActionTimeLine. I saw cpp-tests for both classes and Armature seems to be the one to choose (better performance, smooth transition between different animations, bone access from C++ code, etc.) but as I said on my previous message, using Armature class results in a crash (BAD_ACCESS). I managed to make it work with the ActionTimeLine class, but it lacks some features as I said before.