Hi all,
I'm trying to create a lite version of my game and am currently stuck with integration of AdMob. I want a behavior much like the one in Sapus Tongue Lite - the add should be displayed on the main screen, and disappear once I start the game.
I added the code responsible for AdMob ad in my Main Scene, and by changing the default didReceiveAd method I managed to make the add show up; but the ad remains there for other scenes as well and does not get removed once I change the scene.
The code that inserts the ad on my screen is the following:
- (void)didReceiveAd:(AdMobView *)adView {
NSLog(@"AdMob: Did receive ad");
// get the view frame
CGSize winsize = [[Director sharedDirector] winSize];
CGRect frame = CGRectMake (0,0,winsize.width,winsize.height);
// put the ad at the top of the screen
adMobAd.frame = CGRectMake(0, 0, frame.size.width, 48);
[[[Director sharedDirector] openGLView] addSubview:adMobAd];
[refreshTimer invalidate];
refreshTimer = [NSTimer scheduledTimerWithTimeInterval:AD_REFRESH_PERIOD target:self selector:@selector(refreshAd:) userInfo:nil repeats:YES];
}
also, in dealloc method I'm trying to remove the ad but with no success:
- (void)dealloc {
[adMobAd removeFromSuperview];
[adMobAd release];
[super dealloc];
}
Any ideas?