C++ API Documentation

Setting up the C++ API

Download Browse on Github

You will also need to download boost and curl lib to compile the API. You can download the dependencies package from here.

Visual Studio

Including prebuilt DLL

Configuring project properties

In C/C++ tab

  • Go to General tab
  • Add "(PlaytomicPath)/Include; (DependenciesPath)/Boost;(DependenciesPath)/currlib/include" to Additional include directories

Go to Preprocessor tab

  • Add "LINK_DLL; BOOST_ALL_NO_LIB; JSON_DLL" to Preprocessor Definitions

In Linker tab

  • Go to General tab
  • Add (PlaytomicPath)/Lib/$(Configuration)Dll to "Additional Library Directories"

In Input tab

  • Add "Playtomic.lib" To Additional Dependencies

Using the prebuilt library

Configuring project properties

In C/C++ tab

  • Go to General tab
  • Add "(PlaytomicPath)/Include; (PlaytomicPath)/Include/json/include; (PlaytomicPath)/Include/CurlWrap; (PlaytomicPath)/Include/Tools; (DependenciesPath)/Boost; (DependenciesPath)/currlib/include" to your include directories

Go to Preprocessor tab

  • Add "BOOST_ALL_NO_LIB" to Preprocessor Definitions

In Linker tab

  • Go to General tab
  • Add (PlaytomicPath)/Lib/$(Configuration) to "Additional Library Directories"
  • Go to Input tab
  • Add "libcurld.lib;Playtomic.lib;winmm.lib;ws2_32.lib;wldap32.lib" To Additional Dependencies

Initialize Playtomic API in your game with your game credentials

the autoupdate flag defines if the api create a thread to update the timers if you leave this flag as false you should remeber to update playtomic in your main loop

Playtomic::CPlaytomic *mInstance = new Playtomic::CPlaytomic( SWFId, GUID, true);
mInstance->Init();

Xcode MacOs

Using the prebuilt library

Configuring project properties

In your project target

  • Go to Build Settings
  • Go to Search Paths
  • Add "$(PLAYTOMIC_PATH)/Tools $(PLAYTOMIC_DEPENDENCIES_PATH)/macos/Boost/** $(PLAYTOMIC_PATH)/ $(PLAYTOMIC_PATH)/json/** $(PLAYTOMIC_PATH)/CurlWrap/**" to Header Search Paths
  • Add ""$(PLAYTOMIC_DEPENDENCIES_PATH)/macos/Boost/lib/debug" "(PLAYTOMIC_PATH)/Playtomic/Debug" $(PLAYTOMIC_DEPENDENCIES_PATH)/macos/Boost/lib/release"" to library Search Paths

Go to Build Phases tab

In Link Binary With Libraries

  • Add "libPlaytomic.a"
  • Add "libcurl.dylib"
  • Add "libboost_thread.a"

Initialize Playtomic API in your game with your game credentials

the autoupdate flag defines if the api create a thread to update the timers if you leave this flag as false you should remeber to update playtomic in your main loop

Playtomic::CPlaytomic *mInstance = new Playtomic::CPlaytomic( SWFId, GUID, true);
mInstance->Init();

Xcode iOS

Using the prebuilt framework

Add these frameworks to your game by clicking the project, then selecting the target -> build phases -> expanding Link Binary with Libraries.

  • Curl.framework
  • boost.framework
  • Playtomic.framework

Building from source

  • The playtomic xcode project will call a script to rebuild the framework you can find it at $(project_dir)/bild/Framework/
  • You can find the Curl.framework and boost.framework in the precompiled dependencies $(dependencies_dir)/macos/

Initialize Playtomic API in your game with your game credentials

the autoupdate flag defines if the api create a thread to update the timers if you leave this flag as false you should remeber to update playtomic in your main loop

Playtomic::CPlaytomic *mInstance = new Playtomic::CPlaytomic( SWFId, GUID, true);
mInstance->Init();

Android native

IMPORTANT

To use playtomic in your project you need to compile the project using crystax-ndk since the official ndk don't support all the c++ features we use

Using the prebuilt framework

in your android.mk add:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
PLAYTOMIC_PATH := #your path to playtomic should go here
LOCAL_MODULE := Playtomic-prebuilt
LOCAL_SRC_FILES := $(PLAYTOMIC_PATH)/libs/$(TARGET_ARCH_ABI)/libPlaytomic.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)


#...
#...
#in your project add this

LOCAL_CFLAGS += -fexceptions
LOCAL_CFLAGS += -D__ARM_ARCH_5__
LOCAL_CFLAGS += -D__ANDROID__
PLAYTOMIC_PATH := #your path to playtomic should go here

LOCAL_C_INCLUDES += $(PLAYTOMIC_PATH)/Dependencies/Android/Boost/ \
					$(PLAYTOMIC_PATH)/CurlWrap/ \
					$(PLAYTOMIC_PATH)/Tools/ \
					$(PLAYTOMIC_PATH)/json/include \
					$(PLAYTOMIC_PATH)/Dependencies/Android/curllib/include/ \
					$(PLAYTOMIC_PATH)/Playtomic/ \
                	$(PLAYTOMIC_PATH)/

Permision

In your application AndroidManifest.xml you need to add this

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Initialize Playtomic API in your game with your game credentials

the autoupdate flag defines if the api create a thread to update the timers if you leave this flag as false you should remeber to update playtomic in your main loop

Param Type Description
gameId int your game id number SWFId you can get it from your dashboard
gameguid std::string& your game GUID number SWFId you can get it from your dashboard
javaVMPtr JavaVM* a pointer to the java virtual machine
activity jobject your aplication object, required to access some android sdk features you should make it global calling NewGlobalRef() you can find more information about this in any JNI reference
Playtomic::CPlaytomic *mInstance = new Playtomic::CPlaytomicAndroid(SWFId, GUID, vmPtr, activity, autoUpdate);
mInstance->Init();