集成Admob后,我的Libgdx游戏速度变慢
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了集成Admob后,我的Libgdx游戏速度变慢相关的知识,希望对你有一定的参考价值。
我是一个用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 但不是解决方案如果您有解决方案,请帮助我。
答案
这是一个已知问题,目前你无法改变它。
它与您的代码无关。我认为
以上是关于集成Admob后,我的Libgdx游戏速度变慢的主要内容,如果未能解决你的问题,请参考以下文章