HTTPS SSH

Quick Start Guide for Cocos2d-x

Prerequisites

OS X

  1. XCode

Windows

  1. download and install python 2.7 (only required on windows)
  2. Visual Studio

running the sample

  1. execute install_dependencies.py. This will install a copy of cocos2d-x.
  2. 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)
  3. Open Sample/Classes/AppDelegate.h and change the credentials near line 84
  4. compile, run

Alternatively you case edit Sample/Classes/AppDelegate.h in any editor and execute build_sample.py

Integrating the SDK into your project

  1. Copy the GameSparksSDK directory into your project
  2. 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
  3. 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.

Real-Time Services

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.

Next Steps

Explore the API docs, the Doxygen documentation and the Examples.