Question

I made a game using sprite kit in landscape mode. The only allowed orientations are landscape left and landscape right. When I select the banner ad in my game, rather than freezing the scene and returning to the original point in the game, the entire scene reinitializes itself (music player restarts, content shows as start screen, etc).

The same thing happens when I flip the phone around so that the orientation switches. How can I prevent this?

Était-ce utile?

La solution 2

Thanks for the response. That was the problem. I had been initializing the scene in the viewWillLayoutSubviews method in my root view controller. I moved the scene initialization to the viewDidLoad method and it fixed the issue.

Autres conseils

As for when you flip your phone you need this...

- (void)viewWillLayoutSubviews { 

[super viewWillLayoutSubviews];
SKView * skView = (SKView *)self.view;

if ( !skView.scene ) {...

    SKScene * scene = [MenuScene sceneWithSize:skView.bounds.size];
    scene.scaleMode = SKSceneScaleModeAspectFill;

    [skView presentScene:scene]; 
    } 
}

I'm still looking into the iAd issue, I'll update if I figure anything out.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top