I have been struggling with this for days, for some reason my SKScenes are not deallocating correctly, this results in bounded memory growth as each time i exit and enter a
In a game I'm working on I have a method for going on to the next scene. It looks like this:
func proceedToNextLevel() {
// Go to next level
self.physicsWorld.removeAllJoints()
self.enumerateChildNodesWithName("cube", usingBlock: {
(node: SKNode!, stop: UnsafeMutablePointer ) -> Void in
// do something with node or stop
node.removeFromParent()
})
player.removeFromParent()
hud.removeFromParent()
}
Each level is a scene that inherits this method. (I have a GameScene.swift, and every level is a subclass of it)
This method in each level looks like this:
override func proceedToNextLevel() {
super.proceedToNextLevel()
let transition = SKTransition.revealWithDirection(SKTransitionDirection.Right, duration: 3)
let newScene: LevelFourScene = LevelFourScene.unarchiveFromFile("LevelFourScene") as! LevelFourScene
newScene.scaleMode = SKSceneScaleMode.AspectFit
self.view?.presentScene(newScene)
}
Obviously this is swift and your game is in Objective C but hopefully you get the idea.