Hello,
I am making a video poker application. I want to use a Admob banner ad. I got the code and have used it in my application. I put it in a separate layer for my main game Scene. However, I want to be able to show a partially opaque pay table with the click of a button and have it be brought to the front of all other images/sprites. Admob does not go behind it; it always stays on top. I tried changing Z order of the pay table sprite and changing the order with which the layers are added to the Scene. It did not matter. Is there a method to make the pay table sprite appear on top of the openGLView Subview for the ad?
Below is the Admob ad layer:
#pragma mark -
#pragma mark AdMob Layer
/*
@implementation AdsLayer
// AdMobDelegate methods
- (void)didReceiveAd:(AdMobView *)adView {
// put the ad at the top middle of the screen in landscape mode
adMobAd.frame = CGRectMake(0, 432, 320, 48);
CGAffineTransform makeLandscape = CGAffineTransformMakeRotation(M_PI * 0.5f);
//makeLandscape = CGAffineTransformTranslate(makeLandscape, -216, -134);//centers the ad in landscape mode
makeLandscape = CGAffineTransformTranslate(makeLandscape, -170, -85);//Locates the add in landscape mode
adMobAd.transform = makeLandscape;
[[[CCDirector sharedDirector] openGLView] addSubview:adMobAd ];
}
- (void)onEnter {
adMobAd = [AdMobView requestAdWithDelegate:self];
[adMobAd retain];
[super onEnter];
}
- (void)onExit {
[adMobAd removeFromSuperview];
[adMobAd release];
[super onExit];
}
// Request a new ad. If a new ad is successfully loaded, it will be animated into location.
- (void)refreshAd:(NSTimer *)timer {
[adMobAd requestFreshAd];
}
- (UIColor *)adBackgroundColor {
return [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1]; // this should be prefilled; if not, provide a UIColor
}
- (UIColor *)primaryTextColor {
return [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]; // this should be prefilled; if not, provide a UIColor
}
- (UIColor *)secondaryTextColor {
return [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]; // this should be prefilled; if not, provide a UIColor
}
- (BOOL)mayAskForLocation {
return NO; // this should be prefilled; if not, see AdMobProtocolDelegate.h for instructions
}
@end
Below is my pay table code for the game layer init method:
//Pay Table Button sprite
TSprite *PayTableS = [TSprite spriteWithFile: @"Pays Button.png"];
[PayTableS setScale:percent];
[PayTableS setPosition:ccp(130, _Option_Button_Pos)];
[PayTableS SetCanTrack:YES];//The sprite can be tracked.
[TSprite track:PayTableS];//and lets add this sprite to the tracked array.
[self addChild:PayTableS z:1 tag:kTagPayS];
//Pay Table sprite
TSprite *TableSprite = [TSprite spriteWithFile: @"JoB Pay Table blue.png"];
[TableSprite setScale:percent];
[TableSprite setPosition:ccp(winSize.width/2, (winSize.height/2))];
[TableSprite setVisible:NO];
[self addChild:TableSprite z:3 tag:kTagTable];
And for display in the game layer:
case kTagPayS:
[obj runAction: [CCFadeIn actionWithDuration:0.3]];//lets make the button fade in
if ([[GameController sharedGameController] getPayTable] == NO)
[self schedule:@selector(showPayTable:)] ;
else
[self schedule:@selector(hidePayTable:)] ;
break;
case kTagTable:
[obj runAction: [CCFadeIn actionWithDuration:0.3]];//lets make the button fade in
[self schedule:@selector(hidePayTable:)] ;
break;
I want the user to hit the button sprite with tag 'kTagPayS' to display the pay table with tag 'kTagTable' and then touch anywhere on the pay table (which takes up the whole screen) to hide it again. Currently the Admob banner obstructs some of the text on the image for the paytable.
Thank you for any ideas or help.
Sat Back