In my simple game, I need to remove all SKShapeNodes before the next step happens. Here is the code that I have:
for child in self.children(){
if(child==SKShapeNode(){
child.removeFromParent()
}
}
This does not work because Xcode does not know what to do with child's class. Xcode wants me to add
as! NSObject
after child to "force downcast". This also does not work. I think that this is because now, child will always be an NSObject, not an SKShapeNode.
How do I fix this? I am sure that it is very simple but I cannot seem to fix this myself.
You could do it as follows: