Cocos2dx3.3 use the. csb file exported from cocos studio2.0, cocos2dx3.3. csb
Steps above: (taking the aircraft with the COCOS2DX-JS frame as an example)
1. Open cocos studio2.0 to create a node File
2. Import resources and design new node files as needed
The red box shows the imported resources, the blue box shows the csd file layout (note: the coordinates of the background image are set to (0, 0), and the anchor is set to (0, 0 ), set other element anchor to (0.5, 0.5), Button to Button type, and set the image resources in normal and selected
3. release the project to vs2013 (cocos studio releases the project file as res by default, instead of Resource [do not know how to set the release path], so copy the Resource and generated csb file to the Resource file)
4. Open vs2013 and add the following code:
_rootNode = CSLoader::createNode("menu.csb");this->addChild(_rootNode, 1);auto newBtn = dynamic_cast<Button*>(_rootNode->getChildByName("newBtn"));newBtn->addTouchEventListener(CC_CALLBACK_1(MainScene::newBtnCallback, this));auto optionBtn = dynamic_cast<Button*>(_rootNode->getChildByName("optionBtn"));optionBtn->addTouchEventListener(CC_CALLBACK_1(MainScene::optionBtnCallback, this));auto aboutBtn = dynamic_cast<Button*>(_rootNode->getChildByName("aboutBtn"));aboutBtn->addTouchEventListener(CC_CALLBACK_1(MainScene::aboutBtnCallback, this));
Set the corresponding time listening function to a member function.
// Start the game void MainScene: newBtnCallback (cocos2d: Ref * pSender) {}// option box void MainScene: optionBtnCallback (cocos2d: Ref * pSender) {}// about the void MainScene: aboutBtnCallback (cocos2d: Ref * pSender ){}
5. Compile and run
Note: The above blog post is only a personal learning record. If you have any errors, please leave a message to indicate