#ChartboostX A C++ wrapper of Chartboost for Cocos2d-X. Supports Android and iOS.
#Environment
-
###Chartboost SDK
- Android: v3.0.1
- iOS: v3.1.1
-
###cocos2d-x
- cocos2d-x-2.0.3 or higher
#Example Project
- iOS: example/proj.ios/HelloChartboostX.xcodeproj
- Android: example/proj.android
You need to change the build script (such as build_native.sh) according to your own environment before compiling.
#Add to Your Own Project
iOS and Android will share the same ChartboostX.h
header file. You need add Chartboost-x/ChartboostX.h
to your Classes
folder in the beginning.
All the following files you need in iOS are in Chartboost-x/ios
fold.
- Add the previous
ChartboostX.h
to your Xcode project - Add
CBAnalytics.h
,Chartboost.h
,ChartboostX_ios.mm
,libChartboost.a
to your Xcode project - Ensure you're linking with the following libraries:
- SystemConfiguration.framework
- CoreGraphics.framework
- QuartzCore.framework
- StoreKit.framework (weak-link)
- AdSupport.framework (weak-link, needed in iOS 6)
All the following files you need in Android are in Chartboost-x/android
fold.
-
Add the package
com.wenbin.ChartboostX
and itsChartboostXBridge.java
to your Eclipse project. (You can just add the wholecom
fold tosrc
fold in Eclipse project, and refresh in Eclipse) -
Add the
ChartBoost.jar
file as an external jar to your project. (You can just add theChartBoost.jar
file tolibs
fold in Eclipse project, and refresh in Eclipse) -
Add
ChartboostX_android.cpp
,ChartboostXJni.cpp
andChartboostXJni.h
to yourjni
fold. -
Add
ChartboostX_android.cpp
,ChartboostXJni.cpp
to your jni'sAndroid.mk
. -
In the java implementation of your main activity (which should have been created by the Cocos2d-X script),
import com.wenbin.ChartboostX.*;
-
At the beginning of
onCreate(Bundle savedInstanceState)
, right aftersuper.onCreate(savedInstanceState)
, add the following code:ChartboostXBridge.initChartboostXBridge(this);
-
Add the following code to your main activity:
@Override protected void onResume() { super.onResume(); ChartboostXBridge.initChartboostXBridge(this); }
-
Add the following xml to your Android Manifest file:
Add permission:
<uses-permission android:name="android.permission.INTERNET" />
Add activity:
<activity android:name="com.chartboost.sdk.CBDialogActivity" android:configChanges="orientation|keyboard|keyboardHidden" android:windowSoftInputMode="adjustResize" android:theme="@android:style/Theme.Translucent" android:launchMode="singleTop" > </activity>
##Email: wenbin1989@gmail.com ##Blog: http://geeksavetheworld.com
##You're welcome to contribute. ;-)