Implementing Game Center using COCOS2D-X

Implementing Game Center using COCOS2D-X
0.0 0


I’ve looked around but I can’t really figure it out.

I found this but I’m getting linker errors on the GKAchievementViewController part
I tried this and made a mixed Obj-C C++ class but I get tons of errors like unknown types (but are valid in C++)

Can anyone help me regarding this issue?


Fixed it.

The linker problems was because I haven’t added GameKit.framework in the project and the unknown type problem is because I am importing the cocos2d.h file ( which is a C++ file ) into an Obj-C file.

Case closed.


Great man, it would be of enourmous help to starters if you could post a tutorial on how you implemented Game Centre in cocos2dx on your blog.


Yep, I’m planning that, too but I’m still having problems using Game Center. When I make a fixed version, I’ll write it down.


hey, im trying to add a simple gamecenter leaderboard into my game. ive looked at all the tutorials etc but i cant figure it out.

Since its been 3 months, have you made any progress. if you have any chance you could share a little tutorial? Pleaaase



Adding Game Center requires a bit of knowledge in Objective-C as well as wrapping it on a C*+ class.
I don’t have the time right now but here are some places you might want to look at:
You can wrap Objective-C classes to C*+ classes by creating a new C++ class that has static methods. This class will have the .MM extension instead of the usual .CPP
The static methods will invoke the Obj-C code you need to show the Leaderboards.


Just wanted to add another resource for dealing with Game Center that I have found specially helpful. It is in Japanese, but you just need to add the code that is told.

It looks like it works :slight_smile:


Thanks for the link. I’m wondering what cocos2d-x team members think about including such things as GameCenter wrapped around with cocos2d-x c++ method for easier use. GameCenter etc. seems like something very common to implement in cocos2d-x games so I think it would be nice if cocos2d-x had some methods for this for easier use.


The problem is, GameCenter is limited to iOS (and Mac, probably).


Yes, that is true. But I don’t see a problem to make the wrapper in such way that it just do nothing on other platforms which do not support GameCenter.


If I have the time, I will upload my extension on GitHub and share it on the site. :slight_smile: