3

我找到了用于与 Android 集成的 RevMob 文档。但由于我使用 LibGDX 作为我的框架,所以我完全不知道如何去做。我确实找到了一种集成 AdMob 的方法。但这是一个横幅广告,我想要全屏 RevMob 添加。是 RevMob Docs 的链接。有人能简单地告诉我如何在 LibGDX 中实现它吗?

4

1 回答 1

0

尝试在主 LibGDX 项目中创建一个接口,并像这样在你的 android 项目中实现它......

import android.content.Context;
import android.util.Log;

import com.revmob.RevMob;
import com.revmob.RevMobAdsListener;
import com.revmob.ads.fullscreen.RevMobFullscreen;

public class RevMobDisplay implements AdInterface{

        public RevMobAdsListener listener;
        private RevMobFullscreen fullscreen;


        private MainActivity activity;
        private RevMob revmob;

        public RevMobDisplay(MainActivity mainActivity){
        this.activity = mainActivity;
        revmob = RevMob.start(activity);

        //UNCOMMENT THIS CODE AFTER YOU HAVE PUBLISHED YOUR GAME LIVE
        //USE WHILE TESTING YOUR GAME DURING DEVELOPMENT
        revmob.setTestingMode(RevMobTestingMode.WITH_ADS);

        listener = new RevMobAdsListener() {
        @Override
        public void onRevMobAdDisplayed() {
            Log.i("[RevMob]", "onAdDisplayed");
        }

        @Override
        public void onRevMobAdReceived() {
            Log.i("[RevMob]", "onAdReceived");
        }

        @Override
        public void onRevMobAdNotReceived(String message) {
            Log.i("[RevMob]", "onAdNotReceived");
        }

        @Override
        public void onRevMobAdDismiss() {
            Log.i("[RevMob]", "onAdDismiss");
            fullscreen.hide();
        }

        @Override
        public void onRevMobAdClicked() {
            Log.i("[RevMob]", "onAdClicked");
            revmob.openAdLink(activity, "6753b82ad690ad146c233a6d",this);
        }
    };
          // Pre-load it without showing it
           fullscreen = revmob.createFullscreen(activity, "6753b82ad690ad146c233a6d", listener); 
           revmob.setTimeoutInSeconds(5);
           }


        @Override
        public void showAds(boolean show) {
                if(show){
                        if(fullscreen == null)
                        fullscreen = revmob.createFullscreen(activity, "6753b82ad690ad146c233a6d", listener);
                        fullscreen.show();
                }
                else{
                        fullscreen.hide();
                }          
        }
}

现在你已经实现了一切......将主项目的默认构造函数更改为类似这样

initialize(new MyGame(new RevMobDisplay(this)), cfg); 

现在,您可以随时通过调用轻松地在游戏中展示广告

MyGame.revmobAdInterface.showAds(true);

在此处找到有关将 revmob 与 libgdx 集成的详细教程

http://digitalwolfstudio.in/integrating-revmob-with-libgdx

于 2014-05-13T18:52:04.530 回答