pulitr pulitr - 1 year ago 110
iOS Question

Removing all copies of the SKSpriteNode - Swift

In loop I have this line and I need to remove all copies. Can you help me how to do ? I do in Swift in SpriteKit. Please help me.

obstacles = obstaclesImage.copy() as! SKSpriteNode

Answer Source

Name your nodes:

obstacleCopy.name = "obstacleCopy"

Then enumerate their parent:

self.enumerateChildNodesWithName("enemy") {
    node, stop in 
    if node.name == "obstacleCopy"  { node.removeFromParent()}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download