How to integrate cocostudio with cocos2dx?

I’m looking on the web about this but i got nothing. =\ I have a animation made in cocostudio, and i want implement it in cocos2dx 3.2. So how could i integrate it cocostudio with cocos2d-x 3.2?
Some tutorial?

Load the json definiton of your animation:

cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("myAnimation.json");

Create an armature from the animation data loaded into the ArmatureDataManager:

cocostudio::Armature *armature = cocostudio::Armature::create("myAnimation");

The string has to be the same as your file name without the extension. You can't change it in cocostudio. You have to do it by hand in your json file through the following parameter: "name": "myAnimation"

Add the armature to the layer:

addChild(armature);

Position the animation:

armature->setPosition(Point(centerX, centerY));

Play the first animation in your armature:

armature->getAnimation()->playWithIndex(0);
2 Likes

I tried this. But visual studio doesn’t recognize cocostudio namespace. So i tried include libcocostudio into the solution, and i put #include “cocos-ext.h” on the code, but it did not worked too.

Add $(EngineRoot)cocos\editor-support to your Additional Include Directories.
Then you have to type #include "cocostudio/CocoStudio.h"

Or add $(EngineRoot)cocos\editor-support\cocostudio and you can type #include "CocoStudio.h".

The header files are in cocos2d-x\cocos\editor-support\cocostudio
libCocostudio is the required lib you have to link against.

2 Likes

Thanks man, spent hours not building, you’re a mind reader :smile:

Thought we had to use the “.ExportJson” file? Not that I’d know anything. My “.json” file is two directories into my resource folder on android so I just assumed I could take the contents of the “export” directory from cocosstudio (1x".exportjson" 2x".plist" 2x".png" :smile:) and paste it into the resource directory. Will persevere.

No problem.

Yeah. May I should edit my post. It’s just cause I’m used to it. I modified cocos2d-x, so I can use my atlas files generated by TexturePacker instead of adding the generated ones from the Export folder. CocoStudio generates an atlas per armature, and that’s not how my pipeline works :smile:

So, yes. You just have to load the .ExportJson:

cocostudio::ArmatureDataManager::getInstance()->addArmatureFileInfo("myAnimation.ExportJson");

and copy the stuff form your Export directory to your resource folder.

The difference between the .json and the .ExportJson is, that the latter one stores references to your atlas file and the assets used in the armature, so the assets can be loaded into the SpriteCache/TextureCache automatically.

Additionally I don’t like to use the .png extension in my asset names, but unfortunately it’s not supported by CocoStudio to drop them. This is another reason, I modified the cocos2d-x code to achieve that feature.

Well I was able to setup Visual Studio,
Setup complete Cocos2d-x 3.2 CocosStudio Project.
Utilize the GUI designer, and added physics support.

It works fine with VS2012 on WIn7.

Main Problems are.

  1. Android Device/Simulator fails, due to some unknown issue.
  2. Unable to run on OSX/IOS also due to some unknown issue.

I never developed anything to ios/osx. But to android, did you uncomented
LOCAL_WHOLE_STATIC_LIBRARIES += cocosbuilder_static
and
$(call import-module,editor-support/cocostudio)

on application.mk?

I tried all possible things.

Uncommented libraries in mk file.
Modified glConfig in java.
Removed all audio files from my project.
And much more.
And atlast stopped using 3.2 and switched back to 2.2.3

Please post some screenshot or the error log/console output.