swift - EnumerateChildNodesWithName, Can't seem to Remove nodes -


i'm trying remove nodes parent node once reach x position. problem have parent node changing x position, children not changing x position inside parent (but moving parent), when put in if node.position.x < 300 . . . (remove node), nothing happens. tried below code, work 1 time , doesn't remove nodes again, i'm not 100% sure why stops working.

func cleanup() {     let positionx = nodebase.position.x     nodebase.enumeratechildnodeswithname("segment", usingblock: {         node, stop in         if node.position.x - positionx < 300 {             node.removefromparent()         }     }) } 

can see going wrong code, or can point me in right direction?

try following:

nodebase.enumeratechildnodeswithname("segment") { node, _ in     if !self.intersectsnode(node) {         node.removefromparent()     }  } 

intersectsnode returns true whilst node inside bounds of skscene. therefore, when intersectsnode returns false know node offscreen , can remove node.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -