سؤال

I have a simple spritekit app, SKView on intialization shows a splash screen(scene), the user clicks on a button they are taken to the main game scene.

Everything works fine, but wanted to add iads to it, so I instantiated an adview in the main scene, and assign its delegate to the main scene.

The add appears fine, and I click on it, it properly shows the ad, but then I dismiss the ad, and when I do that the app goes back and looks like it reinitializes the entire SKVIEW which displays the Splash Scene, not the main scene which was paused in the delegate calls.

So, when the IAD is dismissed, what exactly are the callbacks back into the parent app, because its clear its not just the delegate methods, its going back and reinitializing the view etc. Basically where in my view do I need to trap its returning from a canceled ad and handle this case properly.

هل كانت مفيدة؟

المحلول

Sounds like you're running the scene in viewWillLayoutSubviews without checking whether a scene is already running. Make sure the launch code looks like this, or it will relaunch the starting scene whenever the viewWillLayoutSubviews method runs (it can and will be called multiple times, for example when rotating the device and apparently also when dismissing an ad):

-(void)viewWillLayoutSubviews 
{
    SKView* skView = (SKView*)self.view;

    // only create/launch first scene when SKView has no running scene
    if (skView.scene == nil)
    {
        // create and present scene here ...
    }

    [super viewWillLayoutSubviews];
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top