Is there a way to loop through all game objects in a collection? Like a go.get_children() or something?
There isn’t currently that functionality, however it is being discussed within the Defold team I believe (Any way to get the list of children of a game object?).
I will say, generally this isn’t something you should do, in my opinion, it will almost always result in highly-processing intense code, and can almost always be replaced by properly using the messaging system.
If you want to describe your situation I, or others, might be able to provide advice on a potential approach?
Collections don’t exist at runtime, only objects. What exactly are you trying to do?
@SpencerWF For clarity, that feature is for debug purposes, in order to be able to report the scene graph and its properties. It was created in order to be able to create an extension such as extension-poco, which let’s you test/control the game from another computer via python.
I just want to run a few lines of code for all my objects in the collection without having to attach a script to every single object. Just a few lines of setup code that involves grid management.
If there was a way to msg.post() to all those objects then that would work too…I just think that’d be cleaner than having to put code in the init function of every object in my collection.
It’s not a huge deal at this moment but learning how to do something similar would be nice.
Are the objects following a naming convention? You could loop over the objects if you know their names have the same id and a sequence number.
They are not but I just attached a script to each game object… thanks for all your help eveyone.