我在这个游戏中使用 cocos2d-iphone。在一个图层中,我将 admob 添加为弹出广告。我想将 ccMenu 与 admob 视图一起添加,以便在单击 ccmenuItem 后可以删除 admob 视图。但是我怎么知道什么时候加载了 admob 视图呢?
我尝试了以下方法,但无法同时加载菜单项和 admob 视图:
UIViewController *controller=[CCDirector sharedDirector];
CGSize size=[[CCDirector sharedDirector]winSize];
controller.view.frame=CGRectMake(0, 0, size.width, size.height);
_bannerViewTable=[[GADBannerView alloc] initWithFrame:CGRectMake(50, 50, GAD_SIZE_300x250.width, GAD_SIZE_300x250.height)];
_bannerViewTable.adUnitID=@"xxxxxxxxxx";
[_bannerViewTable setRootViewController:controller];
[_bannerViewTable loadRequest:[GADRequest request]];
if (_bannerViewTable!=nil) {
CCLOG(@" _bannerViewTable!=nil");
CCCallFunc *loadView=[CCCallFunc actionWithTarget:self selector:@selector(loadAdTable)];
CCCallFunc *addRemove=[CCCallFunc actionWithTarget:self selector:@selector(addMenuToLayer)];
CCSequence *seq=[CCSequence actionOne:loadView two:addRemove];
[self runAction:seq];
}else{
CCLOG(@" _bannerViewTable=nil");
}
-(void)loadAdTable
{
UIViewController *controller=[CCDirector sharedDirector];
[controller.view addSubview:_bannerViewTable];
}
-(void)addMenuToLayer
{
CCSprite *removeBtn=[CCSprite spriteWithSpriteFrameName:@"minus1.png"];
CCMenuItemSprite *removeImg=[CCMenuItemSprite itemWithNormalSprite:removeBtn selectedSprite:nil target:self selector:@selector(removeAdTable)];
removeImg.position=ccp(343, 282);
menu=[CCMenu menuWithItems:removeImg, nil];
menu.anchorPoint=CGPointZero;
menu.position=CGPointZero;
[self addChild:menu z:1];
}
如何在加载 admob 视图的同时添加删除 ccMenuItem?