Hi,
I upgrade my app to use Cocos2d-x 2.0.3 recently. I cannot figure out how to implement Admob. I know how to do that in 1.x.
I am trying to do this by the xml way. I find that there is no .xml in the layout folder. If I create a .xml in the layout folder and use the code “setContentView(R.layout.main)” to load, it gives me a black screen with an ad on the bottom(no content).
Can someone tell me how to do this?
Thank you very much.
I looking for same solution.
As i can see layouting in 2.0.3 performed in java code.
I tried to add LinearLayout, add cocos2dx FrameLayout in it and then add AdView
But FrameLayout consume all space and give AdView 0px space.
Will be thankful for any solution.
update:
If i add AdView before FrameLayout game screen is overlapped and touch coordinates shifted down
seems that touch coordinates calculated according view size, but GLView uses screen coordinates instead of view
Seems AdView changes size on receive ad, but opengl view remains with same size. It cause game elements out of screen (covered by ad banner)
I tried to modify example to show ad at top of screen, but ad not shows
I will post my code tonight (i’m at work now), i will also try if i have the same problems as you have.
My upcoming game is in landscape, with the example the admob banner was shown in the topleft corner and with a small modification it’s now at the centerbottom.
I had no issues with size changes, normaly the banner has the same size each time?
But when i changed to SMART_BANNER to BANNER i got it down-right aligned inside GL view full screen
What i want to get is vertical stack:
[banner]
[gl-view]
instead of this, banner resides inside gl-view
update:
I removed RelativeLayout and set height of AdView in pixels, after that i get it in vertical stack. (this points to initial zero size of AdView).
But banner fills only 50% width on my 800x480 tablet, and i cannot know what size will be with SMART_BANNER, cause it depends on sceen size and available ads. If use 90px - for smart banner it will take too much space on small screens. Seems it no have universal solution
But when I cope with the Admob, I cannot figure out how can the Admob be disabled (setVisibility(AdView.INVISIBLE)) by using JNI as it always have an java.lang.nullpointerexception when I call it using JNI.
I can already call the java method using JNI in native code
But I cannot control the visibility of the adView inside my activity.java
It seems that even if I don’t call the following code