3

I used chartboost sdk in cocos2d-x game, I can use below code in appDelegate.m and works great...but there is no c++ call for chart boost. How can I call showInterstitial API from c++ file ?

#define CHARTBOOST_APP_ID =@"Here added valid app id from chart boost account"
#define CHARTBOOST_APP_SIGNATURE @"Here added valid signature from chart boost"

Chartboost *cb = [Chartboost sharedChartboost];
cb.appId = CHARTBOOST_APP_ID;
cb.appSignature = CHARTBOOST_APP_SIGNATURE;

[cb startSession];

[cb showInterstitial];

Is there any c++ version of Chartboost SDK ?

UPDATES: Simple solution is to use Obj.C version of Chartboost SDK, then use C++ bridge class in .mm file and access it from other .cpp file. Its simple and best way.

Here is Files: Download

Guru
  • 21,652
  • 10
  • 63
  • 102
  • can you please elaborated more briefly how you actually achieve this ... i also want this using cocos2d-x 3.2 – shaqir saiyed Apr 09 '15 at 11:19
  • @shaqirsaiyed, in above question, see last Download link, download MyChartboostBridge.h file and check...enjoy – Guru Apr 09 '15 at 11:36

4 Answers4

3

There is no C++ version of the Chartboost SDK, however many developers have successfully integrated the SDK in Cocos2d games.

Often they write their own wrapper, but this developer has open sourced his: http://www.cocos2d-x.org/projects/cocos2d-x/assets/11 https://github.com/wenbin1989/Charboost-x

Edz
  • 558
  • 4
  • 8
2

Chartboost provides SDK for iOS development and Android developement.

So the answer is NO. Right now there's no SDK for C++.

Hemang
  • 1,224
  • 9
  • 15
  • yes..searched in chartboost site. But how to use same in cocos2d-x game...I mean how can I call showInterstitial from c++ file ? – Guru Dec 14 '12 at 12:02
  • Your code is proper. Have you setup your CB account and Campaign? – Hemang Dec 14 '12 at 12:05
  • You'll have to create Public Campaign or Cross Promotion Campaign in Chartboost and add your test device. It'll surly work. Let me know if it won't work. – Hemang Dec 14 '12 at 12:06
  • hmm..yes even ads are coming when I use it in appDelegate....that is not a problem, how can I call same thing from c++ code in cocos2d-x game ? – Guru Dec 14 '12 at 12:07
  • From C++ code, it won't work. You can define Global object in AppDelegate and then you can use it in entire game. There's no way to call these functions from C++ code. – Hemang Dec 14 '12 at 12:09
0

Best and safe way is to write your own Obj.C and C++ bridge class.

Here is files and add objectiveC version of Chartboost sdk in Cocos2dx game

Guru
  • 21,652
  • 10
  • 63
  • 102
0

You could do something like this ...

Add this to your AppDelegate.h:

void InitChartBoost();
void ShowInterstitial();

Then create a file AppDelegate.mm and add the following methods:

void AppDelegate::InitChartBoost()
{
    id appDelegate = [[UIApplication sharedApplication] delegate];

    // Initialize the Chartboost library
    [Chartboost startWithAppId:@"your app id"
                  appSignature:@"your app signature"
                      delegate:appDelegate];
}

void AppDelegate::ShowInsterstitial()
{
    [Chartboost showInterstitial:CBLocationHomeScreen];
}
ohthepain
  • 2,004
  • 3
  • 19
  • 30