Importing Into Cocos

This code is useful for importing all objects from Cocos Studio into Cocos to be used in code.

Click on the Publish button in the top left.

255

If you chose to create a Complete Project you will also have the option to Publish To Xcode Project which opens the linked Xcode project and publishes the Cocos Studio files ready for Cocos. If you created a Complete Cocoa2d-JS project then there will also be another option titled Publish To Cocos Code IDE Project.

256

To put the published files into your Cocos project is simple:

  • The published files including any imported assets are located in a folder named res located with the Cocos Studio file
409
  • Copy the res folders contents into your Cocos projects resources folder
  • Use the following code to use the imported object
#include "cocostudio/CocoStudio.h"
  
// put where you want add your cocos studio project
Node *rootNode = CSLoader::createNode( "Filepath to .csb file" );
this->addChild( rootNode );
var rootNode = ccs.load( "Filepath to .json file" );
this.addChild( rootNode.node );

For Cocos2d-JS you will also need to modify the project.json file to include the cocostudio module.

"modules" : ["cocos2d", "cocostudio"],