Individual items added into a displayGroup

Good Afternoon everybody, 

Due to an issue I am having with the physics engine that I don’t think I’ll be able to solve I need to be able to count the number of pieces added to a displayGroup. Normally I would use numChildren to keep track of the number, however I don’t think this is possible. I was wondering if there was a way to double check after initializing numChildren how many items are a part of a displayGroup. 

I was thinking something along these lines here but this solution doesn’t actually return all of items currently onscreen. I tried the below solution and it only returns about 7 when I know I for sure have around 120 items onscreen. 

http://forums.coronalabs.com/topic/33498-count-number-of-objects-on-the-screen/

I might be able to do a workaround to this. I was wondering exactly how numChildren works for a displayGroup, and if I remove an object from screen what would I have to do to decrement numChildren to properly represent the correct amount of objects that are still children of a displayGroup. 

Hi @lbclofy,

The built-in .numChildren property should be correct, representing the number of children in the group at any time. Are you seeing results that don’t yield the correct number?

In your project, why would .numChildren not be possible?

Best regards,

Brent

I might be able to do a workaround to this. I was wondering exactly how numChildren works for a displayGroup, and if I remove an object from screen what would I have to do to decrement numChildren to properly represent the correct amount of objects that are still children of a displayGroup. 

Hi @lbclofy,

The built-in .numChildren property should be correct, representing the number of children in the group at any time. Are you seeing results that don’t yield the correct number?

In your project, why would .numChildren not be possible?

Best regards,

Brent