2
votes

Hello! My game is almost done. But now I want to add ads. I use ADMob. I red the instructions but I don't have a ViewController. Because I am coding in Cocos2d & using SpriteBuilder to connect everything I only have a MainScene.m and MainScene.h.

I don't know what to do. I searched everywhere but can't find anyone in my situation.

Can someone out there please help me? My game is done, it's just the ads left. Then I'm going to pay $99 for the IOS Developer.

Thanks :)

1
CCDirector is the view controller. PS: be sure to test your game on as many devices as possible. Since you are not a registered developer yet you can't have done that, expect some surprises and read through apple's submission guidelines/checklist before submitting.LearnCocos2D
Okey thanks so much! You guys here on Stackoverflow are som welcome to new developers ;)Jonte
But what code should i use? None of the codes I am trying to use seems to workJonte

1 Answers

1
votes

You could try something like this

// ---------------------------------------------------------------------
#pragma mark - Advertising
// ---------------------------------------------------------------------

- (void) createPublicity
{
    bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
    bannerView_.adUnitID = YOUR_GOOGLE_ADMOB_UNIT_ID;
    UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;

    bannerView_.rootViewController = rootViewController;
    [rootViewController.view addSubview:bannerView_];

    GADRequest *request = [GADRequest request];
    [bannerView_ loadRequest: request];
}

- (void) cleanupPublicity
{
    if (bannerView_ != nil)
    {
        [bannerView_ removeFromSuperview];
        bannerView_ = nil;
    }
}