gpt4 book ai didi

android - 如何将 RevMob 与 LibGdx 集成

转载 作者:太空狗 更新时间:2023-10-29 15:09:47 26 4
gpt4 key购买 nike

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

最佳答案

尝试在主 LibGDX 项目中创建一个接口(interface),并像这样在您的 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

关于android - 如何将 RevMob 与 LibGdx 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17887295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com