swiftscenespritebuilder

Chipmunk Error: Cannot remove a body that was not added to the space while changing scenes


I am trying to make a game in Swift, using spritebuilder. I am able to change scenes from my main scene, but when I try to switch scenes from the scene I switched to, the app crashes with this error:

Aborting due to Chipmunk error: Cannot remove a body that was not added to the space. (Removed twice maybe?)

I never use the cpSpaceRemoveBody function, and in Thread 1, remove is called twice automatically (I think this is the problem).

I am switching scenes using:

let scene = CCBReader.loadAsScene("Gameover")
CCDirector.sharedDirector().presentScene(scene)

I have been looking and I can't find anything on why this is happening.


Solution

  • Well, this is embarrassing. I didn't have an onExit method.