2016-01-10 1 views
0

les bannières, j'ai les suivantesComment afficher et masquer les bannières publicitaires dans le jeu en classe? Pour importer

#import "RootViewController.h" 
#import "cocos2d.h" 
#import "platform/ios/CCEAGLView-ios.h" 
#import <iAd/iAd.h> 

@interface RootViewController() 

@end 


@implementation RootViewController 

Pour afficher les bannières publicitaires que je donne les résultats suivants dans mon RootViewController.mm:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 


- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 

    ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50, 320, 50)]; 
    [self.view addSubview:adView]; 
} 

Le problème est dans mon jeu, l'annonce montre tout au long du jeu, et je veux juste que la bannière apparaisse une fois le gameover.cpp initialisé. Comment ferais-je cela? La classe GameOver est en C++ et le RootViewController est en Obj C.

Répondre

0

essayer ce code pour afficher et masquer bannière publicitaire:

- (void)showiAdBanner 
{ 
    if(!_adView) { // only add to view if it's not already there 
     _adView = [[ADBannerView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50, 320, 50)]; //initialize it 
     _adView.delegate = self; // set delegate 
    } 
    _adView.hidden = NO; //reveal it 
    _bannerIsVisible = YES; //set bool to yes 
} 

- (void)hideiAdBanner { 
    _adView.hidden = YES; //hide it 
    _bannerIsVisible = NO; // set bool to no 
} 

appellent cette méthode deux où vous voulez montrer et se cacher.