feature request - cross platform alert message with callback

feature request - cross platform alert message with callback
0.0 0


I think a good api to allow to show alert messages on sny platform would be great.

anyone else believes this feature would be useful?


CCMessageBox, in CCCommon.h
I wrote it one year ago.



I need to explore the framework deeply :-p thanks for the answer


mmm but that messagebox does not provide any delegate or the option to change the text of the buttons, and to set the number of buttons, isn’t it?

Native MessageBox with 2 or 3 buttons

I wrote this for my personal needs, it isn’t a perfect solution, but could come in handy.

void HelloWorld::popupRemoveParticleNO(CCObject *pSender) {
//do stuff

void HelloWorld::popupRemoveParticleYES(CCObject *pSender) {
//do stuff

CCAlertView *alert = CCAlertView::create("Remove particle", "Are you sure?", "No", "Yes", this, callfuncO_selector(HelloWorld::popupRemoveParticleNO), callfuncO_selector(HelloWorld::popupRemoveParticleYES));
this->addChild(alert, 100);


I was talking about a native looking alert, but this is awesome, and might be very useful for almost any kind of game.

I’d like to see something similar to this implemented some day with the framework :slight_smile:

Thanks for sharing Bojan!


This is very interesting, it will be very useful if this is added to official github repo.


Zhe Wang wrote:

CCMessageBox, in CCCommon.h
I wrote it one year ago.

That’s good. But it’s limited because there is only one button allowed. Is it possible to use two buttons,like “yes”,“no”?


Yes, an option for two or even three buttons would be useful.


any other votes to request this feature?


I vote to add this feature too, if possible, I want to say the same thing that Leszek Leszek say.
An option for two or even three buttons will be very useful.


I needed two button native allert for ios so I wrote a simple wrapper for easy use with cocos2d-x. Feel free to use it for any purpose. Usage example:

#include "CCAlert.h"
void SomeLayer::SomeMethod()
    CCAlert::Show("Title", "Text", "Yes", "No", this, alert_selector(SomeLayer::AlertCallback));
void SomeLayer::AlertCallback(bool firstButtonPressed)
    if (firstButtonPressed)
        // yes pressed
        // no pressed



Thanks for ccAlert class,that was of great help.

How can i implement the same class for android?


cocos2dx team, pleeeasseeee include this in the main branch! :smiley:


It will be great if it’s included. I vote up too. :slight_smile:


I agree, it would be great to have this as part of the library. I’ve built my own for each platform, and it has been kind of a nuisance (especially for Android and it’s mad JNI). Having it as part of the library would be brilliant.



anyone has an android version of this ?