每次我尝试在SpriteKit中加载以前加载的场景时,我的应用程序崩溃了。
我使用以下代码:
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
/* Called when a touch begins */
for touch : AnyObject in touches {
let locationF = touch.locationInNode(self)
if levelsButtonBack.containsPoint(locationF){
let goToy = inicio(fileNamed: "inicio")
scene?.view?.presentScene(goToy!, transition: SKTransition.fadeWithDuration(0.03))
}
}
}
presentScene()
行会在我的应用中导致此崩溃:
2015-12-20 11:53:40.630 Ball[19425:620103] *** Terminating app due to uncaught exception
'Cant add body, already exists in a world', reason: 'Cant add body <SKPhysicsBody> type:<Rectangle> representedObject:[<SKSpriteNode> name:'(null)' texture:['nil'] position:{110, 300} scale:{1.00, 1.00} size:{200, 70} anchor:{0.5, 0.5} rotation:0.00], already exists in a world' *** First throw call stack: –
如何解决此错误?