2012-07-13 68 views
0

我正在構建由AndEngine遊戲框架支持的Android遊戲。
我使用下面的代碼通過AdMob inegrate:AdMob集成失敗線程在AndEngine應用程序上正常工作

@Override 
protected void onSetContentView() { 
    mRenderSurfaceView = new RenderSurfaceView(this, mEngine); 
    mRenderSurfaceView.applyRenderer(); 
    setContentView(R.layout.main); 

    final FrameLayout frameLayout = new FrameLayout(this); 
    final FrameLayout.LayoutParams frameLayoutLayoutParams = 
      new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, 
             FrameLayout.LayoutParams.FILL_PARENT); 


    AdView adView = new AdView(this, AdSize.BANNER, "XXXXXXX"); 
    adView.refreshDrawableState(); 
    adView.setVisibility(AdView.VISIBLE); 
    final FrameLayout.LayoutParams adViewLayoutParams = 
     new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, 
            FrameLayout.LayoutParams.WRAP_CONTENT, 
            Gravity.CENTER_HORIZONTAL|Gravity.BOTTOM); 

    AdRequest adRequest = new AdRequest(); 
    adRequest.addTestDevice(AdRequest.TEST_EMULATOR);  
    adRequest.addTestDevice(Secure.ANDROID_ID); 
    adView.loadAd(adRequest); 

    final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams = 
     new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams()); 

    frameLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams); 
    frameLayout.addView(adView, adViewLayoutParams); 

    this.setContentView(frameLayout, frameLayoutLayoutParams); 
} 

在遊戲中,當球在創建它使一個衰落的動畫
我對主題進行:

new Thread(new Runnable() { 

     public void run() { 
      mBody.setType(BodyType.StaticBody); 
      mSprite.setAlpha(0.0f); 
      try { 
       while(mSprite.getAlpha() < 1.0f) { 
        mSprite.setAlpha(mSprite.getAlpha() + 0.01f); 
        Thread.sleep(3); 
       } 

       mBody.setType(BodyType.DynamicBody); 
       mBody.setLinearVelocity(new Vector2(0, 10)); 

      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } 

     } 
    }).start(); 

的問題是:
動畫作品完美,但
當我加入AdMob聯播代碼雪碧出現第二
然後,剛剛消失。

在我看來,這兩個代碼塊之間存在問題。
但我不能把我的手指放在解決方案,甚至是什麼導致這個問題發生。

我只知道在我的應用程序中組合Admob代碼時動畫不起作用。

我想知道爲什麼以及如何解決它。 謝謝你們

回答

0

這可能是完全不相關的,但我最近有一個隨機消失的Sprites的問題,雖然沒有與Admob連接。當我將該行添加到設置引擎的位置時,問題就消失了:

engineOptions.getRenderOptions().disableExtensionVertexBufferObjects(); 
0

我建議你使用XML文件來放置你的管理員。它更乾淨,易於使用,根據我自己的測試,它比壓倒性的初始內容快。爲了達到這個目的,你需要擴展LayoutGameActivity(如果我沒有錯的話,還有一個SimpleLayoutActivity的簡單版本)

我會在計算機上改進答案。

相關問題