Why cant i move an iAd from a HUD layer?

67 Views Asked by At

I have a HUD layer containing an iAd with a function that moves the ad offscreen. I use this code to add the HUD layer to one of the scenes I have:

CCScene *scene = [CCScene node];

hudLayer *hud = [hudLayer node];
[scene addChild:hud z:1 tag:5];

MainMenuView *layer = [[[MainMenuView alloc] initWithHud:hud] autorelease];
[scene addChild:layer];

return scene;

hudLayer is the iAd class file name.

Now when I go to another scene the HUD layer is still there even if I added it in another scene. I tried solving this problem by moving the iAd's position with this code:

-(void)hideBanner:(BOOL)sender {
   if (sender) {
      [bannerView setCenter:CGPointMake([CCDirector sharedDirector].winSize.width/2,
                                        320+bannerView.frame.size.height/2)];
   }
   else {
      [bannerView setCenter:CGPointMake([CCDirector sharedDirector].winSize.width/2, 
                                        320-bannerView.frame.size.height/2)];
   }
}

On the scene I added the HUD layer I have a button that calls a function that switches scene to another and calls the function above using this code:

hudLayer *a = [[hudLayer alloc] init];
[a hideBanner:YES];

The function gets called but the iAd doesn't move. I tried calling the same function from the HUD layers init function and the iAd gets moved but not when another scene calls it.

0

There are 0 best solutions below