【问题标题】:Admob Interstitial Cocos2d Objective CAdmob Interstitial Cocos2d Objective C
【发布时间】:2015-05-07 17:20:02
【问题描述】:

我在谷歌上搜索,但我只找到了将 AdMob 横幅视图集成到我在 Cocos2d 中的应用程序的方法。现在我需要全屏 AdMob 插页式广告,但我找不到这样做的方法:。请帮助我,我该怎么做?

我不确定我需要发布什么源代码...我想在应用启动和游戏结束时显示插页式广告。

我已经试过this

但它给了我一些错误。

【问题讨论】:

  • cocos2d 3.x 还是 cocos2d 2.x ?

标签: ios objective-c xcode cocos2d-iphone admob


【解决方案1】:

在 AppDelegate.h 中,添加 GADInterstitialDelegate

@interface AppController : NSObject <UIApplicationDelegate, CCDirectorDelegate, GADInterstitialDelegate>
{
}
-(void)showAdmobFullScreenAds;
@end

#define App ((AppController *)[[UIApplication sharedApplication] delegate])

在 AppDelegate.m 中

-(void)showAdmobFullScreenAds
{
    GADInterstitial  *interstitial_ = [[GADInterstitial alloc] init];
    interstitial_.adUnitID = @"ca-app-pub-YOUR_ID";
    interstitial_.delegate = self;
    [interstitial_ loadRequest:[GADRequest request]];

}

- (void)interstitialDidReceiveAd:(GADInterstitial *)interstitial
{
    [interstitial presentFromRootViewController:[CCDirector sharedDirector]];
}

// 在GameOver类中,添加#import "AppDelegate.h" 然后使用下面的函数

   [App showAdmobFullScreenAds];

【讨论】:

  • 我的应用程序 delegate.h 现在有这个:@interface AppController : NSObject 这是个问题吗?
  • 好的,我做到了,现在在 app delegate.m 上说 void showadmofullscreenads 出现错误:使用未声明的标识符 'shoAdmobFullScreenAds' 我至少需要输入?
  • 对于哪个变量显示未声明的标识符?
  • 对于 -(void)showAdmobFullScreenAds,但我通过放在最后一行来解决这个问题....但现在它说另一个错误:在“appController*”类型的对象上找不到属性“navigationController” ' 在 [mInterstitial_ presentFromRootViewController:self.navigationController] 行中;感谢您的快速回复:)
  • 你用的是哪个版本的cocos2d?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多