gpt4 book ai didi

libgdx - 我的 Libgdx 游戏在集成 Admob 时速度很慢

转载 作者:行者123 更新时间:2023-12-02 11:36:12 25 4
gpt4 key购买 nike

我是一个用libgdx开发的新游戏。我的 Admob 广告有问题。当我调用“adView.loadAd(adRequest);”时我的游戏很慢,当我开始游戏时,FPS ~ 60,当我调用 adView.loadAd(adRequest) 时,我的游戏很慢 FPS ~ 30。

这是我的

public class MainActivity extends AndroidApplication implements IActivityRequestHandler {

protected AdView adView;
AdRequest adRequest;
private final int SHOW_ADS = 1;
private final int HIDE_ADS = 0;

protected Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SHOW_ADS: {
System.out.println("SHOW ADVIEW");
adView.setVisibility(View.VISIBLE);
break;
}
case HIDE_ADS: {
adView.setVisibility(View.GONE);
break;
}
}
}
};

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Create the layout
RelativeLayout layout = new RelativeLayout(this);

// Do the stuff that initialize() would do for you
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);

// Create the libgdx View
View gameView = initializeForView(new MyGdxGame(this), false);

// Create and setup the AdMob view`enter code here`
adView = new AdView(this, AdSize.BANNER, "XXXXXX"); // Put in your
// secret key
// here
adRequest = new AdRequest();
adView.loadAd(adRequest);
// adView.loadAd(new AdRequest());

// Add the libgdx view
layout.addView(gameView);

// Add the AdMob view
RelativeLayout.LayoutParams adParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

layout.addView(adView, adParams);

// Hook it all up
setContentView(layout);
}

// This is the callback that posts a message for the handler
@Override
public void showAds(boolean show) {
handler.sendEmptyMessage(show ? SHOW_ADS : HIDE_ADS);
}
}

我阅读主题 Using interstitials from Admob in a Libgdx game for Android, it's slow when dismissing it
但不是解决方案如果您有解决方案,请帮助我。

最佳答案

这是一个已知问题,目前您无法更改它。

Post at the libgdx Forum

这与你的代码无关。我认为

关于libgdx - 我的 Libgdx 游戏在集成 Admob 时速度很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21594662/

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