2014-02-06 48 views
3

我是一個用libgdx開發的新遊戲。 Admob廣告存在問題。當我稱之爲「adView.loadAd(adRequest);」我的遊戲是slowl,當我開始遊戲,FPS〜60,當我打電話adView.loadAd(AdRequest中)我的遊戲是慢慢FPS〜30我的Libgdx遊戲整合速度慢Admob

這裏是我的

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
但不是解決方案 如果您有解決方案,請幫助我。

回答

1

這是一個已知的問題,目前你不能改變它。

Post at the libgdx Forum

它與你的代碼沒有任何待辦事項。我認爲

+0

感謝您的評論。我的問題似乎只發生在我的設備上:D.我試過其他設備,它工作得很好:) – kaseru

+0

你很好。這仍然是一個已知問題,取決於設備。有些設備的工作速度爲60fps,而下降到30fps – BennX