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];
}
}
我猜你在viewcontroller的viewWillLayoutSubviews
方法中运行presentScene
而不保护这个方法在某些情况下会重复运行的事实,例如调整视图大小时。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.