Add Admob with Cocos2d-x on IOS

Source: Internet
Author: User
Tags admob

Add Admob with Cocos2d-x on IOS(2013-02-27 14:12:00) reproduced
Tags:

C=blog&q=it&by=tag "target=" _blank "style=" text-decoration:none; Color:rgb (62,115,160); White-space:nowrap ">it

1. Download AdMob, setup your account2. Add AdMob to Xcode project. You need:-Add LIBGOOGLEADMOBADS.A to bundle libraries-Create a group and add AdMob header file3.In AppController.h, add Member:

@interface AppController: NSObject <</span>uiaccelerometerdelegate, uialertviewdelegate,uitextfielddelegate , Uiapplicationdelegate, gadbannerviewdelegate> {

uiwindow *window;

rootviewcontroller *viewcontroller;

gadbannerview * bannerview_;

}


4. In appcontroller.mm

// setup AdMob

 

//Create A view of the standard size in the bottom of the screen.

//Available Adsize Constants is explained in GADAdSize.h.

&NBSP;      Bannerview_ = [[ Gadbannerview alloc "  initwithadsize : Kgadadsizebanner;

bannerview_. Delegate = self;

//Specify the ad ' s "unit identifier." This is your AdMob Publisher ID.

bannerview_. Adunitid = @ "your_id";

 

//Let the runtime know which Uiviewcontroller-to- Restore after taking

//The user wherever the ad goes and add it to the view hierarchy.

&NBSP;      Bannerview_ Rootviewcontroller =  viewcontroller

[ viewcontroller.  View Addsubview :bannerview_];

 

 

//Initiate a generic request to load it with an ad.

gadrequest * adrequest = [gadrequest request];

[Bannerview_ loadrequest: adrequest];


/ /Start Game

cocos2d:: ccapplication:: sharedapplication () Run ();






5. We is not over yet!!!

You'll have exceptions if running the app now. You must does this:

(Http://stackoverflow.com/questions/12635283/admob-crashes-with-gadobjectprivate-changestate-unrecognized-selector)

-OBJC   to the  other Linker Flags   of your application target ' s build setting:

  1. Click the Blue Top-level project icon in XCode
  2. Choose your target and go to Build Settings
  3. Under other Linker the Flags add -ObjC for both Release and Debug

Done !!! Let's make money and go IPO:)

Add Admob with Cocos2d-x on IOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.