문제

i have a Problem with Sprite kit using more than one SKScene. Every time when I change the device orientation, sprite kit presents the first SKScene. When I flip the iPhone, the game scene disappears and the device is showing the menu scene.

How can i fix this?

도움이 되었습니까?

해결책

Thank You for your help. I solved it with "if ( !skView.scene ) {...}":

- (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 guess you run presentScene in the viewcontroller's viewWillLayoutSubviews method without safeguarding against the fact that this method will run repeatedly under certain circumstances, such as when the view is resized.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top