How do Cocos Studio button callbacks work?

I’ve searched everywhere for this with no luck. How do I set up a simple button in Cocos Studio and have it run code in the cocos2d-x scene? I saw one example in chinese that I had translated but it was a lot of code just to do a button callback, and I couldn’t get it to work.

Does anyone have a simple example of getting a button from Cocos Studio to run the callback code?

Same. I can’t figure out how to use a simple button either. This is crazy :dizzy_face:

I figured it out finally.

ui::Button *button = static_cast<ui::Button*>(layer->getChildByName("play_button")); // 'play_button' or whatever name you called it in cocos studio
button->addTouchEventListener(CC_CALLBACK_2(MainMenuScene::PlayButtonCallback, mainMenuScene)); // obviously use your own callback and scene here.

Then here is your callback function that it will run, again should be renamed to what you used above

void MainMenuScene::PlayButtonCallback(Ref *pSender, ui::Widget::TouchEventType type)

Can you please post code for java script version?

http://www.cocos.readme.io/v1.0/docs/widgets-button

For more visit SonarLearning

http://cocos2d-x.org/programmersguide/6

Scroll down to Button

Aro was looking for buttons through Cocos Studio, something that isnt found in the programmers guide. The link provided has much more detailed information and should be the official reference

We will be adding a Cocos Studio chapter.

In what? 3 years? 4? Ive been on this site and all I ever find are broken links, irrelevant information about older versions and flat out unanswered questions. THIS IS WHY AMERICANS STRUGGLE TO USE YOUR ENGINE. Please stop telling us what cocos2dx can do for developers and actually post some guides. Thanks for the link that read me is helplfu.

I’m not sure I agree. I’m American and I don’t struggle. When I hit a road block. I read and study the source. I ask fellow developers.

If you find broken links, please let me know.

flat out unanswered questions, I’m always sorry when this happens, but in fact we can only answer so many in a given day. We have many users here that also spend a lot of time answering questions for the good of the community.

We have a guide: http://cocos2d-x.org/programmersguide

We are adding to it with each release.

If you have things you want to see in the guide, please send a PR so we can review it.

I agree with isn63683, most of the information I find is outdated.It’s frustrating. Simple internet searches for my problems give many results of people asking the same questions on other sites such as stackoverflow. The guys who run the cocos2d-x site should remove all outdated and old information. Most of their links and guides no longer apply and just send you in circles.

thank you. i thought i was going crazy for a while searching for simple information.