Closed GoogleCodeExporter closed 8 years ago
the for loop problem. the problem occurs everywhere. if a add 30 sphere, and
remove
them with the for loop then the loop loops through 50%.
first loop, 30 objects -> remove 15
second loop, 15 objects -> remove 8
thrid loop, 7 objects -> remove 4
fourth loop, 4 objects -> remove 2
fifth loop, 2 objects -> remove 1
sixth loop, 1 object -> remove 1
i don't understand, am i the only one with this problem?
Original comment by samoverd...@gmail.com
on 27 Aug 2009 at 1:22
the problem here is that you are removing children at the start of the array.
this
causes the remaining children to shuffle along by one. but in the next loop,
you have
incremented your index by one! so yes, this way will strip every other child
object
in the loop. if you want to remove all children without this problem, you should
iterate your index value from the end of the array, so that no objects are
shuffled
along.
Original comment by rob.bate...@gmail.com
on 15 Sep 2009 at 11:21
Original issue reported on code.google.com by
samoverd...@gmail.com
on 24 Aug 2009 at 4:31