2014-09-01 23 views
0

这是我的第一个雪碧游戏,出于某种原因,我遇到的唯一困难是admob集成。 这是我的viewDidLoad如何将Admob插页式与Sprite Kit集成?

- (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; 
} 

到目前为止好,AdMob的是火的时候,游戏装载。现在我想在每次用户输掉比赛时都解雇他。 现在整个游戏都运行到我的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的日志被调用,但没有广告显示出来。 任何建议将不胜感激。

回答

0

而不是

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

试试这个

[self showAdmobFullscreen]; 
+0

那是我第一次尝试。广告加载在一个类(例如FirstViewController),我想在其他类(如SpriteView)中加载广告,所以我将FirstViewController的类导入到SpriteView,我可以看到在输出(NSLogs我做了)它正在加载,但没有任何显示。 – XcodeNOOB 2014-09-01 12:01:21