如何将Admob Interstitial与Sprite Kit集成?

时间:2014-09-01 08:22:24

标签: xcode admob sprite-kit

这是我的第一款雪碧游戏,由于某种原因,我遇到的唯一困难是admob集成。 这是我的ViewDidLoad

- (void)viewDidLoad
{
[super viewDidLoad];

// showing for the first time my AdMob Interstitial
[self showAdmobFullscreen];

// Configure the view.
SKView * skView = (SKView *)self.view;

SKScene *mc = [GameScene01 sceneWithSize:skView.bounds.size];

mc.scaleMode = SKSceneScaleModeAspectFill;

[skView presentScene:mc];
}

这是我的Admob设置:

-(void)showAdmobFullscreen{
NSLog(@" showAdmoBFullScreenCalled");

//    self.interstitial_ = [[GADInterstitial alloc] init];
//    self.interstitial.delegate = self;
//    self.interstitial.adUnitID = ADMOB_FULLSCREEN_ID;
//    [self.interstitial loadRequest:[self adMobrequest]];
interstitial_ = [[GADInterstitial alloc]init];
interstitial_.delegate = self;
interstitial_.adUnitID = @"ca-app-pub-1032576214759203/773434443";
[interstitial_ loadRequest:[self adMobrequest]];
}

   - (GADRequest *)adMobrequest {
     NSLog(@"requestHasBeenCalled");

     GADRequest *request = [GADRequest request];
        request.testDevices = @[
                        // TODO: Add your device/simulator test identifiers here. Your device             identifier is printed to
                        // the console when the app is launched.

                        //@"9481d65c607d68c867a51229a3c61340"
                        ];
return request;
}

到目前为止很好,当游戏加载时,这个混血儿很火。现在我想在每次用户输入游戏时触发它。 现在整个游戏都进入了我的Sprite文件,我尝试过的是每次有GameOver时调用'showAdmobFullscreen' 所以在我的Sprite.m文件中,我有一个名为GameOver的方法,我添加了这些行:

-(void)GameOver
{
//Trying to make Admob shows whenever User loses a game

MyMainViewController *spVc = [[MyMainViewController alloc]init];
[spVc showAdmobFullscreen];

我可以看到我的Admob的日志被调用但没有广告出现。 任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

而不是

 MyMainViewController *spVc = [[MyMainViewController alloc]init];  
    [spVc showAdmobFullscreen];

试试这个

[self showAdmobFullscreen];