2013-12-13 25 views
0

有誰能告訴我如何配置圖表助推添加平臺和引擎遊戲中顯示添加的遊戲。 我已經下載了SDK chartboost,我試圖像配置ChartBoost在onCreateEngineOption -使用Chartboost和andengine在遊戲中顯示添加

public EngineOptions onCreateEngineOptions() 
    { 
     camera = new BoundCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); 
     EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new FillResolutionPolicy(), this.camera); 
     engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);//turn on the music and sound option 
     engineOptions.getRenderOptions().getConfigChooserOptions().setRequestedMultiSampling(true); 
     engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);//tell the engine to always keep the screen unloced while game is running 
     engineOptions.getRenderOptions().setDithering(true);//enable the Dithering for the whole game by default 
     return engineOptions; 

     // Configure Chartboost 
     this.cb = Chartboost.sharedChartboost(); 
     String appId = "YOUR_APP_ID"; 
     String appSignature = "YOUR_APP_SIGNATURE"; 
     this.cb.onCreate(this, appId, appSignature, null); 
    } 

和我的遊戲崩潰... 謝謝!

回答

1

我已經想通了如何通過自己整合Chartboost在Andengine遊戲

步驟1)初始化Chartboost在OnCreateEngineOption

//ChrtBoost Code 
    cb = Chartboost.sharedChartboost(); 
    String appId = "****************"; 
    String appSignature = "****************************"; 
    cb.onCreate(this,appId,appSignature, null); 
    cb.onStart(this); 
    cb.setImpressionsUseActivities(true); 
    //end of chartBoost Code 

步驟2)啓動會議在onCreateResource方法

this.runOnUiThread(new Runnable() { 
     public void run() { 

      cb.startSession(); 
      cb.showInterstitial(); 

       } 
    }); 

步驟3緩存附加的最初使用onCreateScene方法

//cache the adds initially 
    this.cb.cacheInterstitial(); 

步驟4顯示添加在場景中調用下面的方法

cb.showInterstitial(); 
0

Chartboost希望添加到標準android活動的視圖中,而不是作爲引擎的一部分。您應該使用SimpleLayoutGameActivity作爲您的遊戲活動,以便您可以爲您的廣告服務提供XML佈局。

看看在XMLLayoutExample (https://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/XMLLayoutExample.java

還是來看看這個舊的實現我使用andengine GLES1發而回。需求將會類似。這使用AdMob而不是Chartboost,但您的應用程序崩潰的原因是相同的:您需要使用自定義的XMLlayout來使您的廣告投放起作用。

https://github.com/zfoley/AndengineAdmobLayoutExample

希望這可以讓你在正確的軌道上!

相關問題