I found I needed a modal alert dialog, and I wanted it to be cross-platform.
Rombos had a blog post for a cocos2d-iphone one he did:
It seemed sane, so I spent the morning porting it to cocos2d-x/C*+ — the main difference from his version is that Objective-C has those helpful code-block/anonymous function/lambda thingies that C*+ doesn’t have. [Correct me if I’m wrong!] So instead the C++ version requires SEL_CallFunc functions and targets to call them on.
The code is up on github for anyone that wants to try it:
One thing I don’t like about it, is that it requires images for the dialog background and button backgrounds to be in your project. They’re supplied, and you can replace them with similar sized versions of your color-scheme/art-style, but I kind of wish that was optional.
Let me know if you find any bugs (I’ll be sure to blame them on Rombos ).
Also let me know if these work on other platforms: I’ve only tried them on iOS.