[Open Source!] Modal Alerts for Cocos2d-x!

[Open Source!] Modal Alerts for Cocos2d-x!
0

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: https://rombosblog.wordpress.com/2012/02/28/modal-alerts-for-cocos2d/). 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 :wink: ).

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)
4 Likes

Wow. Want some help testing. I have an idea for a game that is modal alert based.

1 Like

Feel free to play around with it! Let me know if there are any issues with the integration instructions, I’m hoping it should be clear enough! :slight_smile:

Forgot to say yesterday, but there’ll be a great deal more open source projects over the next few months! There’s quite a few parts of Asterun which I’ve been able to isolate out, and a few new bits which’ll (hopefully) be of great use to some of you! :smiley:

1 Like