2012-12-14 96 views
3

我在cocos2d-x遊戲中使用了chartboost sdk,我可以在appDelegate.m中使用下面的代碼並且效果很好......但是沒有C++調用圖表增強功能。我如何從C++文件調用showInterstitial API?Cocos2D-X遊戲中的Chartboost

#define CHARTBOOST_APP_ID [email protected]"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]; 

Chartboost SDK是否有任何C++版本?

更新: 簡單的解決方法是使用Chartboost SDK的Obj.C版本,然後使用C++橋類.mm文件,並從其他.cpp文件訪問它。它簡單和最好的方式。

以下是文件:Download

+0

你可以pl便於闡述更簡單,你實際上是如何做到這一點...我也想利用這個cocos2d的-X 3.2 –

+0

@shaqirsaiyed,在上面的問題,見最後下載鏈接,下載MyChartboostBridge.h文件,並檢查...享受 – Guru

回答

3

Chartboost SDK沒有C++版本,但許多開發人員已成功將SDK集成到Cocos2d遊戲中。

他們常常自己寫的包裝,但開發者已經開源了他: http://www.cocos2d-x.org/projects/cocos2d-x/assets/11 https://github.com/wenbin1989/Charboost-x

+3

這些鏈接已經過了404。請更新。 –

+3

請更新鏈接 –

+3

請更新鏈接.. –

2

Chartboost爲iOS開發和Android的研究與開發提供SDK。

所以答案是否定的。目前,C++沒有SDK。

+0

yes..searched在chartboost網站。但如何在cocos2d-x遊戲中使用相同的...我的意思是我怎樣才能從C++文件調用showInterstitial? – Guru

+0

你的代碼是正確的。您是否設置了您的CB賬戶和Campaign? – Hemang

+0

您必須在Chartboost中創建公共廣告系列或交叉促銷活動並添加您的測試設備。它會很好的工作。讓我知道如果它不起作用。 – Hemang

0

最好最安全的辦法是寫自己的OBJ。 C和C++橋接類。

Here is files和Cocos2dx遊戲添加Chartboost SDK中的ObjectiveC版本

0

你可以做這樣的事情......

添加到您的AppDelegate.h:

void InitChartBoost(); 
void ShowInterstitial(); 

然後創建一個文件AppDelegate.mm並添加以下方法:

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]; 
}