【问题标题】:Cocos2d: What a the black stripe below CCGLSurfaceView?Cocos2d:CCGLSurfaceView 下方的黑色条纹是什么?
【发布时间】:2014-03-21 17:19:26
【问题描述】:

我正在尝试在游戏场景下添加 Admob 横幅,但一些黑色条纹与横幅的一半重叠。 我删除了横幅,看看是否是 Admob 的问题,但条纹仍然存在。

我怎样才能删除它?或者有什么办法可以在黑色条纹上显示横幅?

来源:

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

        adView = new AdView(this);
        adView.setAdSize(AdSize.BANNER);
        adView.setAdUnitId("xxxxxxxxx");

        AdRequest adRequest = new AdRequest.Builder().addTestDevice(
                AdRequest.DEVICE_ID_EMULATOR).build();

        adView.loadAd(adRequest);
        adView.setBackgroundColor(Color.BLACK);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        mGLSurfaceView = new CCGLSurfaceView(this);

        background = new LinearLayout(this);
        game_layout = new LinearLayout(this);
        ad_layout = new LinearLayout(this);

        background.setOrientation(LinearLayout.VERTICAL);
        ad_layout.setOrientation(LinearLayout.VERTICAL);
        game_layout.setOrientation(LinearLayout.VERTICAL);

        ad_layout.addView(adView);
        game_layout.addView(mGLSurfaceView);

        LinearLayout.LayoutParams game_params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1f);
        background.addView(game_layout, game_params);

        LinearLayout.LayoutParams ad_params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        background.addView(ad_layout, ad_params);
        this.setContentView(background);
    }

    public void onStart() {
        super.onStart();
        CCDirector.sharedDirector().attachInView(mGLSurfaceView);
        CCDirector.sharedDirector().setDisplayFPS(true);
        CCDirector.sharedDirector().setAnimationInterval(1.0f / 60.0f);
        CCScene scene = GameStartLayer.scene();
        CCDirector.sharedDirector().runWithScene(scene);
    }

【问题讨论】:

    标签: java android cocos2d-android


    【解决方案1】:

    我终于找到了游戏场景过度播放banner的原因。 这个错误其实很傻。

    以下方法必须更新:

        @Override
        public void onPause() {
            **if (adView != null) adView.pause();**
            super.onPause();
            CCDirector.sharedDirector().pause();
        }
    
        @Override
        public void onResume() {
            super.onResume();
            CCDirector.sharedDirector().resume();
            **if (adView != null) adView.resume();**
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      • 1970-01-01
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多