You cannot delete
a SKScene
. I would recommend creating a function for when your present the scene. Here is and example
(Swift)
func deleteView(deleteEveryThing:Bool) {
if deleteEveryThing {
self.removeAllActions()
self.removeAllChildren()
//Scene presentation code here
}
else {
self.removeAllChildren()
//Scene Presentation Code here
}
}
(Objective - C)
-(void)deletView:(BOOL)deleteEveryThing {
if (deleteEveryThing) {
[self removeAllNodes];
[self removeAllActions];
}
else {
[self removeAllNodes];
[self removeAllActions];
}
}
So what I did was create a function called deleteView
and deleteView
has a parameter that is a Boolean (True or false) and if it is trure then it will remove all actions : self.removeAllActions() or [self removeAllActions];
and all children: self.removeAllChildren() or [self removeAllChildren];
in the SKScene
. This can help in freeing up memory and once those two lines of code ran then you can handle the scene presentation code. There is also an else part which does the same thing but leaves the SKActions
in the SKScene
.