K1m Posted May 22, 2015 Share Posted May 22, 2015 How to remove items (sprites) from group, if I know only their coordinates. I did this:my_group.forEach(function(item) { if (item.x == 10 && item.y == 10) { my_group.remove(item); }});and have error Cannot read property 'x' of undefined Link to comment Share on other sites More sharing options...
rich Posted May 22, 2015 Share Posted May 22, 2015 When you loop copy 'item' into a local array. After the forEach loop run through the array and call 'remove' on each one. K1m 1 Link to comment Share on other sites More sharing options...
K1m Posted May 22, 2015 Author Share Posted May 22, 2015 Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts