0

谁能告诉我如何在 And 引擎游戏中配置 Chart boost add 平台以在游戏中显示添加。我已经下载了 chartboost sdk,我正在尝试在 onCreateEngineOption 中配置 ChartBoost,例如 -

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

我的游戏崩溃了......谢谢!

4

2 回答 2

1

我已经自己弄清楚了如何将 Chartboost 集成到 Andengine 游戏中

步骤 1)在 OnCreateEngineOption 中初始化 Chartboost

//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 方法中启动 Session

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

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

              }
    });

步骤 3缓存 add 最初使用的 onCreateScene 方法

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

第 4 步显示添加到您的场景调用以下方法

cb.showInterstitial();
于 2014-04-01T07:01:40.817 回答
0

Chartboost 期望被添加到标准 android Activity 的视图中,而不是作为 andengine 的一部分。您应该使用 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

希望这能让你走上正轨!

于 2013-12-13T20:18:56.647 回答