Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>UPDATES: Refer generalised answer here: <a href="https://stackoverflow.com/questions/14278166/admob-banner-integration-in-cocos2d-2-0-admob-banner-in-iphone-games/14296630#14296630">Admob-banner-integration-in-cocos2d</a></p> <p>I hope already u got solution. If not then here is all code for Admob integration in cocos2D game.</p> <pre><code> #define ENABLE_ADMOB 1 //#define COCOS2D_2_0 1 @interface MyMainMenu : CCLayer { #ifdef ENABLE_ADMOB GADBannerView *mBannerView; #endif } @implementation MyMainMenu -(void)onEnter { [super onEnter]; #ifdef ENABLE_ADMOB #ifdef COCOS2D_2_0 AppController *app = (AppController*)[[UIApplication sharedApplication] delegate]; #else AppDelegate* app = (AppDelegate*)[[UIApplication sharedApplication] delegate]; #endif mBannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; // Specify the ad's "unit identifier." This is your AdMob Publisher ID. mBannerView.adUnitID = MY_BANNER_UNIT_ID; // Let the runtime know which UIViewController to restore after taking // the user wherever the ad goes and add it to the view hierarchy. //size #ifdef COCOS2D_2_0 mBannerView.rootViewController = app.navController; [app.navController.view addSubview:mBannerView]; #else mBannerView.rootViewController = app.viewController; [app.viewController.view addSubview:mBannerView]; #endif // Initiate a generic request to load it with an ad. [mBannerView loadRequest:[GADRequest request]]; CGSize AdSize = kGADAdSizeBanner.size; CGRect frame = mBannerView.frame; frame.origin.y = -50.0f; #ifdef COCOS2D_2_0 frame.origin.x = (app.navController.view.bounds.size.width - AdSize.width) / 2 ; #else frame.origin.x = (app.viewController.view.bounds.size.width - AdSize.width) / 2 ; #endif mBannerView.frame = frame; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.5]; [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; frame = mBannerView.frame; frame.origin.y = 0.0f; mBannerView.frame = frame; [UIView commitAnimations]; #endif } -(void)showBannerView { if (mBannerView) { [UIView animateWithDuration:0.5 delay:0.1 options: UIViewAnimationCurveEaseOut animations:^ { CGRect frame = mBannerView.frame; frame.origin.y = 0.0f; mBannerView.frame = frame; } completion:^(BOOL finished) { }]; } } -(void)hideBannerView { if (mBannerView) { [UIView animateWithDuration:0.5 delay:0.1 options: UIViewAnimationCurveEaseOut animations:^ { CGRect frame = mBannerView.frame; frame.origin.y = -50.0f; mBannerView.frame = frame; } completion:^(BOOL finished) { }]; } } -(void)dismissAdView { #ifdef ENABLE_ADMOB if (mBannerView) { [UIView animateWithDuration:0.5 delay:0.1 options: UIViewAnimationCurveEaseOut animations:^ { CGRect frame = mBannerView.frame; frame.origin.y = -50.0f; mBannerView.frame = frame; } completion:^(BOOL finished) { [mBannerView setDelegate:nil]; [mBannerView removeFromSuperview]; mBannerView = nil; }]; } #endif } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload