Quick Start Guide for Cocos2d-x
running the sample
- execute install_dependencies.py. This will install a copy of cocos2d-x.
- Open one of the project file located at GameSparksSample/proj.* in you IDE (note that the Android Studio project does not support building from inside the IDE unless you specify cocos as external build tool as described here: http://discuss.cocos2d-x.org/t/how-can-i-use-android-studio-together-with-cocos2d-x-any-hints/7365)
- Open Sample/Classes/AppDelegate.h and change the credentials near line 84
- compile, run
Alternatively you case edit Sample/Classes/AppDelegate.h in any editor and execute build_sample.py
Integrating the SDK into your project
- Copy the GameSparksSDK directory into your project
- Add the source files to your project:
2.1 Either add all the .cpp, .c and .mm files located at GameSparksSDK/src/** to your project
2.2 Or add GameSparksSDK/src/GameSparksAll.cpp to your project.
2.3 On iOS and macOS you'll also need to add GameSparksSDK/src/GameSparks/GSIosHelper.mm and GameSparksSDK/src/UNIX2003_Fix.c
- Add GameSparksSDK/include to your include search paths
One thing to note is, that the SDK is not thread-safe. So you have to do locking yourself. However the SDK only ever calls any callbacks from within a call to Update(). So you always know which thread is calling your callbacks.
The sample uses the GameSparks Real-Time Services have a look at the tutorials for the Real-Time Services. The API of the C++ SDK is very simmilar to the .NET SDK, so most of the sample code should be easy to adapt.
The Real-Time Services require C++11 so make sure to update your project settings.