Recently I’ve released two iOS games (with Javier Rodríguez Vidal‘s and Víctor Grau Moreso‘s help). Both games use Cocos2d-x engine and a custom open source framework built on top of it named MawKit which I want to introduce in this post.
Why another framework?
We started developing Hop Raider last year’s November. At that moment there was a beta project called SDKBox focused on providing cross-platform plugins to Cocos2d-x but our experience was pretty frustrating: ads plugins which used outdated third-party APIs and spammy log-level, leaderboards/achievements plugins really buggy, almost no support for OS X, not-well documented plugins and features missing.
So we decided to develop our own solution, originally focused on offering a cross-platform (Android, iOS, OS X) implementation for ads and leaderboards/achievements, and called it MawKit. We developed the first version as we wrote Hop Raider and refactored it to make it open-source when we developed Blimp Journey.
It is written in C++, Java and Objective-C++ and offers callbacks to handle asynchronous operations, avoiding busy-waiting and global variables. MawKit is fully documented with Doxygen although we are working on improving Github’s documentation at the moment.
What does MawKit offer?
MawKit includes platform-specific implementation for features like:
- Leaderboards and achievements (Google Play Games on Android and GameCenter on iOS/OS X).
- Ads (Admob and AdColony on both iOS and Android – noop implementation for OS X as there is no oficial SDK for this platform).
- In-app purchases.
As well as cross-platform utilities like:
- Mathematical helpers (random number generator, ranges).
- A simple key-value database with local persistence.
FiniteTimeActions(move a node to the position of a different node, regardless it is static or in movement, shake a node, etc).
- Logging utilities (prepending prefixes to the logged message to easily identify their priority)
- Infinite parallax nodes (both vertical and horizontal).
- Device utilities (get screen’s size, hardware performance and motion sensors coming soon).
- Fabric‘s Answer (all platforms) and MixPanel (iOS) support.
Here are some nice snippets:
- Storing money with
- Reporting new score:
- Checking whether an achievement is unlocked:
- Showing an ad:
- Throwing a dice:
- Moving a node to the position of another moving node (bonus: this snippet is part of Hop Raider):
- Getting current language:
Ideas, suggestions, contributions…
… are welcomed as Github issues or pull requests.