首页 文章

Admob Interstitial Cocos2d目标C.

提问于
浏览
1

我在谷歌搜索,但我只找到在我的应用程序中集成AdMob Banner 视图的方法在Cocos2d . 现在我需要将全屏AdMob放在插页式广告中,我找不到办法: . 请帮帮我,我怎么做?

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

我已经试过this

但它给了我一些错误 .

1 回答

  • 3

    在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];
    

相关问题