Hey there everyone!
A little while ago I released my first open-source project, which allows for native cocos2d-x ‘Modal Alerts’ in the theming and style of your games!
I started development on this extension from using Cocos2d-iPhone v2, based upon the open-sourced Cocos2D-iPhone v1 objective-c version (found here: Modal Alerts for Cocos2D | The Rombos-Blog). I ended up rewriting it for v2 for one of my projects. It then got rewritten again for Cocos2d-SpriteBuilder v3, before ending up being brought over to Cocos2d-x for my latest game, Asterun! (please click the shiny link to the left ).
This means that instead of using Apple’s UIAlertView class or another platform’s equivalent, you can have alerts that look like:
I know right… shiny…
To get a basic ModalAlert showing, you simply use:
ModalAlert::tell("Hello!", this, 30, [&]() {
// place code here to reenable any background items (buttons etc)
});```
where you provide the alert message _("Hello"_), the parent node you're displaying the alert on (such as a layer, '_this_'), the font size (_30_), and the completion block to call once the alert has been totally removed.
To have a look at the code and get it integrated, check out https://github.com/ryanbourneuk/ModalAlertCocos2d-x!
There's a few bits I'll be adding to this over time, and as this was my first major C++ project it'll probably get cleaned up considerably too. If you have any cool ideas, please do feel free to contribute!
Hope y'all enjoy!
[@ryanbourne28](http://twitter.com/ryanbourne28)