2014-09-01 58 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