Integrating Admob in Cocos2dx Windows/ Windows Phone Project | Techbirds
For integrating Admob in the Windows/ Windows Phone. You need the following things.
- Coco2dx 2.2.3 version (below this version windows/windows phone. Don’t support Admob)
- Admob Sdk
The main reason for taking the Cocos2dx 2.2.3 version is because before this version the Cocos2dx don’t support the XAML project version for windows/ windows phone & without the XAML support you cant integrate Admob in windows/windows phone.
Once you have download the Cocos2d 2.2.3 version. Extract the contents in a folder.
to create a project you can refer the following link .
After you create the project you see a WP8 XAML project. Open this project in Visual Studio for Phone. you see a Phone Xaml and Direct3D type of project.
In a Phone Xaml and Direct3D of application we have a XAML page. On that page we have a DrawingSurfaceBackgroundGrid in which the rendring of the Cocos2dx project is done.
So once we get the XAML page we all know how to integrate adMob on that. For those who don’t know how to add Admob below is the code. Before writing the code don’t forget to add the Admob SDK to you project and Admob AdUnitID to the code below.
//on XAML add a grid name “ads”
//on XAML add a grid name “ads”
|
//on Page Load add the following ads.Children.Add(Ad_Control()); public AdView Ad_Control() { AdView bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = “AdUnitID of AdMob” }; bannerAd.ReceivedAd += OnAdReceived; bannerAd.FailedToReceiveAd += OnFailedToReceiveAd; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; bannerAd.LoadAd(adRequest); return bannerAd; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
//on Page Load add the following ads.Children.Add(Ad_Control()); public AdView Ad_Control() { AdView bannerAd = new AdView { Format = AdFormats.Banner, AdUnitID = “AdUnitID of AdMob” }; bannerAd.ReceivedAd += OnAdReceived; bannerAd.FailedToReceiveAd += OnFailedToReceiveAd; AdRequest adRequest = new AdRequest(); adRequest.ForceTesting = true; bannerAd.LoadAd(adRequest); return bannerAd; } |
2,438 total views, 1 views today
Share this On