Iterate over a group when no collision occurs?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

Hi all,

I have a large number of sprites They’re instanced into my level scene. As I added them to the level scene, I added each one to a group, called “bricks”.

So as it stands, I have a level, there are about 300 of these sprites and they are all in the “bricks” group.

I want to parse through each “brick”, retrieve its statistics and do specific work on each one.

Everywhere I look when researching a solution is groups and in particular is_in_group().
The problem is I can only find the ability to use this if there is a collision. For example: body.is_in_group("group name") comes up a lot. I’m not using collisions though.

Is there a way to parse over the items in my “bricks” group without collisions happening? It MUST be something simple but I’ve spent an hour looking and have had no luck.

Any advice would be really appreciated.

… and I think I found it!

var bricks = get_tree().get_nodes_in_group("bricks")
    for i in bricks:
        #do stuff

Will report back…

Robster | 2017-04-18 11:05

check call_group too, may be better or not, depending on the “do stuff” part.

eons | 2017-04-18 12:45

:bust_in_silhouette: Reply From: Robster

Answering for completeness…

var bricks = get_tree().get_nodes_in_group("bricks")
    for i in bricks:
        #do stuff