Admob的在cocos2d和SpriteBuilder [英] Admob in Cocos2d and SpriteBuilder

查看:162
本文介绍了Admob的在cocos2d和SpriteBuilder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!我的游戏几乎已经完成。但现在我想添加广告。我使用的AdMob。我红的指示,但我没有一个的ViewController。因为我的编码在cocos2d和放大器;使用SpriteBuilder连接一切,我只有一个MainScene.m和MainScene.h。

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.

有人可以在那里帮帮我吗?我的游戏做,这只是广告左侧。然后,我要付$ 99的iOS开发者。

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.

感谢:)

推荐答案

您可以尝试这样的事情

// ---------------------------------------------------------------------
#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;
    }
}

这篇关于Admob的在cocos2d和SpriteBuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆