T
T
Timu4en2014-12-04 02:54:06
iOS
Timu4en, 2014-12-04 02:54:06

SpriteKit (Objective-c): what to do if the banners visible in one scene are visible in all scenes when switching to it?

I inserted banners in the Game Over scene but after jumping to that scene, the banners show up in all scenes in the game.
I have the banner code in the main GameViewController. To load a banner in my scene, I inserted this code before the scene declaration:

- (void)loadAdBanner {
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    GameViewController *vc = (GameViewController *)delegate.window.rootViewController;
    [vc initADBanner];
}

Call inside the scene: [self loadAdBanner ];
Transition to game scene:
GameScene * myScene = [[ GameScene alloc ] initWithSize : self.view.bounds.size ];
        [ self.view presentScene: myScene  ];

I beg your help, I'm a beginner and it's still difficult for me to get to everything myself.
Google couldn't help me.

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
F
Flie, 2014-12-07
@Flie

As far as I know, SpriteKit does not use other controllers. The root controller itself loads all the scenes. Therefore, if you force it to show your banner, it will show it regardless of the scene currently being shown. Try to shift the mechanism of creating a banner and the view that shows it to a specific scene where it is required.

T
Timu4en, 2014-12-11
@Timu4en

Thanks, exhaustive. I suspected this, but in all the demos and examples, banners are loaded into the root controller. until I can't properly organize the methods in a particular scene. I get errors all the time, even when I'm 100% sure the code is correct.
Thanks for responding.

P
Petr Volkhanov, 2017-03-30
@eprivalov

The problem was caching.

S
Shamsudin Serderov, 2017-03-25
@Steein

This service will help you , I myself constantly use the @font-face generator

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question