cocos2dx3.3. csb files that are exported using Cocos studio2.0

Source: Internet
Author: User
Tags button type

Directly on the steps: (with the Cocos2dx-js frame comes with an airplane for example)

1. Open Cocos studio2.0 new node file



2. Import the resources and design the new node files as needed



The red box is the imported resource in the blue box for the layout of the CSD file (note that the background map coordinates are set to (0,0), the anchor point is set to (0,0), the other element anchors are set to (0.5,0.5), the buttons are set to the button type, and the picture resource is set to normal and selected

3. Publish the project to vs2013 (Cocos Studio default Publish project file is res, not resource[does not know how to set the publishing path], so the resource and generated CSB file is copied to the resource file)

4. Open vs2013, 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")); O Ptionbtn->addtoucheventlistener (Cc_callback_1 (Mainscene::optionbtncallback, this)); Auto AboutBtn = dynamic_cast <Button*> (_rootnode->getchildbyname ("aboutbtn")); Aboutbtn->addtoucheventlistener (Cc_callback_1 ( Mainscene::aboutbtncallback, this));


The corresponding time listener function is set to the member function to

Start game void Mainscene::newbtncallback (cocos2d::ref* psender) {}//option box void Mainscene::optionbtncallback (cocos2d::Ref* Psender) {}//about box void Mainscene::aboutbtncallback (cocos2d::ref* psender) {}


5. Compile and run


Note: The above blog is only a personal study record, if there are errors, please note that the message

cocos2dx3.3. csb files that are exported using Cocos studio2.0

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: info-contact@alibabacloud.com 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.