I made it and created Khalou, a reflection board game.
The most difficult part was to create bindings.
I would like to share my work, hoping this will help other people and contributors to Cocos2d-x.
The goal of my game is to make a completely white board by flipping stones following 2 types of moves.
I can’t give you any download link, but I took as many screens as I can.
http://image.noelshack.com/fichiers/2012/52/1356540670-capture-d-ecran-2012-12-26-a-17-31-48.pngConnected to the GameCenter:
http://image.noelshack.com/fichiers/2012/52/1356540679-capture-d-ecran-2012-12-26-a-17-36-22.pngEndGame with iAd integration:
http://image.noelshack.com/fichiers/2012/52/1356540684-capture-d-ecran-2012-12-26-a-17-36-49.pngSharing with Facebook:
So far, it’s impossible to call native functions without creating bindings, so I’ll tell you my procedure.
You can also first look at the github that I used to help me
https://github.com/funkaster/cxx-generatorblobmaster/README.mdI made a singleton for facebook in Obj-C, here is
@interface FacebookHelper_objc : NSObject
@property (strong, nonatomic) NSMutableDictionary *postParams;
@property (nonatomic, retain) Facebook *facebook;
- (BOOL) publishScore:(int) score;
+ (FacebookHelper_objc*) sharedFacebookHelper;
So, when I want to call publishScore, I do
[[FacebookHelper_objc sharedFacebookHelper] publishScore:score];
I put this in a static function of a C*+ class, inside the
and create the class, here the header
static bool publishScore;
Don’t forget to put your methods public
Next, I created the bindings. I used the cxx-generator joined in the tools, and used the
, with the file
You need to tell to the script the paths to the different header directories through this file.
It was certainly the most painful part of my project, because I used the OSX C*+ library, that uses sometimes other keywords, like
After satisfying all the header required for the binding generation, I put all the generated files (facebook_bindings.cpp, facebook_bindings.hpp, facebook_bindingsapi.js) into my project.
In fact, It has a lot more difficult and long to make bindings for me, because of dependences of the bindings generator.
I would make soon a public github project with that game, but I can’t yet… I want to share my great (and creepy) code to you, because that’s the most interesting.
Sorry, but the second (the bigger) *.ini file joined in this post is the good one, and I don’t know how to delete old files.
userconf.ini.zip (0.3 KB)
BindingsHelper.ini.zip (0.8 KB)