xcode - Multiple Child Nodes in EnumerateChildNodesWithName -
i'm removing , adding nodes using enumeratechildnodeswithname. wondering if there way of using enumeratechildnodeswithname multiple names. example, @ moment using below:
nodebase.enumeratechildnodeswithname("ground", usingblock: { node, stop in if node.position.x + positionx < -self.frame.size.width/2 - sizesegmentwidth/2 { node.removefromparent() } }) nodebase.enumeratechildnodeswithname("obstacle", usingblock: { node, stop in if node.position.x + positionx < -self.frame.size.width/2 - sizesegmentwidth/2 { node.removefromparent() } })
but i'm hoping (this doesn't work, example of i'm trying do):
nodebase.enumeratechildnodeswithname("ground" || "obstacle", usingblock: { node, stop in if node.position.x + positionx < -self.frame.size.width/2 - sizesegmentwidth/2 { node.removefromparent() } })
you do:
enumeratechildnodeswithname("*") { node, _ in if node.name == "ground" || node.name == "obstacle" { // ... } }
"*"
means you'll enumerate on nodes children of scene (assuming it's scene calling enumeratechildnodeswithname
). if wanted check all nodes instead use "//*"
.
Comments
Post a Comment