我使用以下代码在SK场景之间导航:
SKScene *newScene = [[MyScene alloc] initWithSize:self.size state:state];
float duration = 1;
SKTransition *transition = [SKTransition fadeWithDuration:duration];
[self.view presentScene:newScene transition:transition];
无论我想要呈现的场景类型如何,应用程序每次都会使用EXC_BAD_ACCESS(代码1)崩溃而没有任何僵尸..看起来“现在的场景在xcode6上无法正常工作,它在我之前工作了”从xcode5升级
编辑:这是initWithSize代码:
-(id)initWithSize:(CGSize)size state:(GameState)state{
if (self = [super initWithSize:size]) {
[self setupScene];
if (state == GameStateLaunch) {
[self setupLoadingScreen];
[self switchToLaunch];
} else if (state == GameStateTutorial || state == GameStateReplay) {
[self switchToTutorial];
} else if (state== GameStateMainMenu) {
[self switchToMainMenu];
}
}
return self;
}
我设法通过在呈现新场景之前移除所有孩子来使其部分工作:
- (void)cleanUpChildrenAndRemove {
for (SKNode *child in self.children) {
[child removeFromParent];
}
[self removeFromParent];
}
然而,这很疯狂。必须有更好的解决方案!