cocos2d-x 3.0 beta2 版本在 安卓 上无法正常显示广告

我描述一下问题,以前一直用的2dx 2.2版本,做安卓版本嵌入广告时,是将广告view添加到Cocos2dxActivity中的frameLayout这个变量。
目前更新到3.0beta2版本之后,首先找不到frameLayout这个变量了,我尝试自己在Cocos2dxActivity类中用setContentView或addContentView添加一个能在游戏界面之上显示的view,但结果总是无法显示,感觉是被2dx的渲染层盖住了。

求解决!

非常感谢。

新的3.0使用了nativeactivity,应该是这个影响的,具体还要再研究一下。

非常感谢您的回复

是这样的,我这个项目因为目前卡在这里,比较着急。
我也不太想轻易退回到旧的引擎,请问能否提供一些hotfix之类的解决方法呢?

http://www.dynadream.com/ddweb/index.php/Special_Blog

http://www.cocos2d-x.org/forums/6/topics/35619

精华:

package com.yourcompany. youractivityname;

import android.app.NativeActivity;

import android.widget.PopupWindow;

… (Other imports here)

import com.google.ads.*;

public class youractivityname extends NativeActivity

{

AdView adView;

PopupWindow popUp;

youractivityname _activity;

LinearLayout layout;

LinearLayout mainLayout;

boolean adsinited = false;

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

// Make your custom init here

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

_activity = this;

// Create our ad view here

adView = new AdView(_activity, AdSize.BANNER, “changethiswithyouradmobid”);

}

// Our popup window, you will call it from your C/C++ code later

public void showAdPopup()

{

if(adsinited)

{

return;

}

if(adView!=null) {

_activity.runOnUiThread(new Runnable() {

@Override

public void run() {

adsinited = true;

// Out popup window

popUp = new PopupWindow(_activity);

// This is the minimum size for AdMob, we need to set this in case our target device run at 320x480 resolution (Otherwise no ad will be shown, see the padding kill below)

popUp.setWidth(320);

popUp.setHeight(50);

popUp.setWindowLayoutMode(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

popUp.setClippingEnabled(false);

layout = new LinearLayout(_activity);

mainLayout = new LinearLayout(_activity);

// The layout system for the PopupWindow will kill some pixels due to margins/paddings etc… (No way to remove it), so padd it to adjust

layout.setPadding(-5, -5, -5, -5);

   MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

params.setMargins(0, 0, 0, 0);

layout.setOrientation(LinearLayout.VERTICAL);

layout.addView(adView, params);

popUp.setContentView(layout);

_activity.setContentView(mainLayout, params);

AdRequest adRequest = new AdRequest();

// Enable this if your are testing AdMob, otherwise you’ll risk to be banned!

//adRequest.addTestDevice(AdRequest.TEST_EMULATOR);

_activity.adView.loadAd(adRequest);

// Show our popup window

popUp.showAtLocation(mainLayout, Gravity.BOTTOM, 0, 0);

popUp.update();

}});

}

}

// Do some cleanup

@Override

public void onDestroy() {

if (adView != null) {

  adView.destroy();

}

super.onDestroy();

}

}

楼主解决了吗?求解答 我的qq:435666609

:3: :3: :3: :3: :3: :3: :3:

banner的问题可以用以上方式解决,但像微信sdk这种还是不行,只能等引擎版本更新了

纠结 由native 又换成java的了

这样换也是不得已而为之。具体可见此链接:http://www.cocos2d-x.org/forums/6/topics/48163

:883: 之后的方向还是使用Native?

没解决黑屏的问题之前估计都是java activity。。。:14::14::14: