Cocos2dx3.3 use the. csb file exported from cocos studio2.0, cocos2dx3.3. csb

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.