{"_id":"54e47d6a610dfd0d00b2a84a","project":"5463e333447e0a100024a087","version":{"_id":"5463e333447e0a100024a08a","project":"5463e333447e0a100024a087","__v":6,"createdAt":"2014-11-12T22:46:11.486Z","releaseDate":"2014-11-12T22:46:11.486Z","categories":["5463e333447e0a100024a08b","54645c365871e90800f50151","547b1c5a4366a708001b3b50","547b1cdf4366a708001b3b5a","54e3bef8464a9c3700f7ca67","54ec651d7ab3172d00c01ab7"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":7,"user":"54639d06447e0a1000249f7f","category":{"_id":"54e3bef8464a9c3700f7ca67","pages":["54e3bfabe887c50d005ef6a0","54e3c35ee887c50d005ef6af","54e3c9ade887c50d005ef6b4","54e3ca68e887c50d005ef6b6","54e47d6a610dfd0d00b2a84a","54e487250e41ef2b00b996c2","54e48ec60e41ef2b00b996cd","54e5c6e8e662e60d00aff673","54e5d4efe0b92439007d6999","54e5dc0ae0b92439007d69aa","54e72c88e6e77d1900ed10fa","54e7391f3c1e111700d05749","54e73f1a3c1e111700d05757","54e863f5c8e0c00d007abffd","54e86704a64fba0d00846860","54e86abb32b0b00d00c960f2","54e9e881560f2b170087f1d0","54e9eca2a6f14f0d003e96b5","54e9f04d560f2b170087f1d3","54eb2041996da20d00e6d68e","54eb801659b1172100334ffc","54eb8101df7add210007b31a","54ec584cc0c0ba1700386f8d","54ec5adad17b6d2300a54d75","54ec5e077ab3172d00c01aae","54edf8ca1e4ee60d0018e89f","54edfbc0130818170073a16b","54edff0e8dafa7250027e659"],"project":"5463e333447e0a100024a087","__v":28,"version":"5463e333447e0a100024a08a","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-17T22:21:44.099Z","from_sync":false,"order":2,"slug":"cocos-studio","title":"Cocos Studio"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-02-18T11:54:18.557Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":9,"body":"This code is useful for importing all objects from **Cocos Studio** into Cocos to be used in code.\n\nClick on the **Publish** button in the top left.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/jVzBUBfScOohDsonAu7O_Screen-Shot-2015-02-18-at-11.45.31.png\",\n        \"Screen-Shot-2015-02-18-at-11.45.31.png\",\n        \"255\",\n        \"245\",\n        \"#7c91ae\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIf 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.* \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/t7ZDDUt6TsStoeHUCAEV_Screen%20Shot%202015-02-18%20at%2011.53.51.png\",\n        \"Screen Shot 2015-02-18 at 11.53.51.png\",\n        \"256\",\n        \"238\",\n        \"#6e8ab2\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nTo put the published files into your Cocos project is simple:\n  * The published files including any imported assets are located in a folder named **res** located with the Cocos Studio file\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Wk3MUOR4TeK4eEUiPr5d_Screen%20Shot%202015-02-18%20at%2012.03.07.png\",\n        \"Screen Shot 2015-02-18 at 12.03.07.png\",\n        \"409\",\n        \"134\",\n        \"#056cdb\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n  * Copy the **res** folders contents into your Cocos projects resources folder\n  * Use the following code to use the imported object\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#include \\\"cocostudio/CocoStudio.h\\\"\\n  \\n// put where you want add your cocos studio project\\nNode *rootNode = CSLoader::createNode( \\\"Filepath to .csb file\\\" );\\nthis->addChild( rootNode );\",\n      \"language\": \"cplusplus\",\n      \"name\": \"Cocos2d-x C++\"\n    },\n    {\n      \"code\": \"var rootNode = ccs.load( \\\"Filepath to .json file\\\" );\\nthis.addChild( rootNode.node );\",\n      \"language\": \"javascript\",\n      \"name\": \"Cocos2d-JS\"\n    }\n  ]\n}\n[/block]\nFor **Cocos2d-JS** you will also need to modify the **project.json** file to include the **cocostudio** module.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\\"modules\\\" : [\\\"cocos2d\\\", \\\"cocostudio\\\"],\",\n      \"language\": \"javascript\",\n      \"name\": \"Cocos2d-JS\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"importing-a-scene-into-cocos","type":"basic","title":"Importing Into Cocos"}

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. [block:image] { "images": [ { "image": [ "https://files.readme.io/jVzBUBfScOohDsonAu7O_Screen-Shot-2015-02-18-at-11.45.31.png", "Screen-Shot-2015-02-18-at-11.45.31.png", "255", "245", "#7c91ae", "" ] } ] } [/block] 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.* [block:image] { "images": [ { "image": [ "https://files.readme.io/t7ZDDUt6TsStoeHUCAEV_Screen%20Shot%202015-02-18%20at%2011.53.51.png", "Screen Shot 2015-02-18 at 11.53.51.png", "256", "238", "#6e8ab2", "" ] } ] } [/block] 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 [block:image] { "images": [ { "image": [ "https://files.readme.io/Wk3MUOR4TeK4eEUiPr5d_Screen%20Shot%202015-02-18%20at%2012.03.07.png", "Screen Shot 2015-02-18 at 12.03.07.png", "409", "134", "#056cdb", "" ] } ] } [/block] * Copy the **res** folders contents into your Cocos projects resources folder * Use the following code to use the imported object [block:code] { "codes": [ { "code": "#include \"cocostudio/CocoStudio.h\"\n \n// put where you want add your cocos studio project\nNode *rootNode = CSLoader::createNode( \"Filepath to .csb file\" );\nthis->addChild( rootNode );", "language": "cplusplus", "name": "Cocos2d-x C++" }, { "code": "var rootNode = ccs.load( \"Filepath to .json file\" );\nthis.addChild( rootNode.node );", "language": "javascript", "name": "Cocos2d-JS" } ] } [/block] For **Cocos2d-JS** you will also need to modify the **project.json** file to include the **cocostudio** module. [block:code] { "codes": [ { "code": "\"modules\" : [\"cocos2d\", \"cocostudio\"],", "language": "javascript", "name": "Cocos2d-JS" } ] } [/block]