• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Puts differents object in a group (or assign a tag)

L

Loïc Mouton

Guest
Hi everyone !

I've a question about GML, i'm young in the world of GML programming and i'm ask myself is it possible to put multiple object under a single tag ? Like if i have 6 different plateform object, can i put on them a "platform" tag ?

Thanks for your answers !
 

TailBit

Member
Yes, you can use parents for that ..

for example I got obj_solid that is parent for obj_wall and obj_semi .. and I give my fully solid walls obj_wall as parent while all my semi solid ones got the other one ..that way I can still find any of them with obj_solid
 
R

robproctor83

Guest
You can do like TailBit says, BUT if you need the parenting for something else, or if you need objects to be in multiple groups you will need to use something else. Off-hand I don't believe there is any built in feature like parenting for that, you will need to do something else with a data structure, or maybe even an array. Technically you will need probably need 2 axis of data (think of a simple x / y graph where Y is the group and X is the object. So, for something like that you would use a grid, but like I said you could also do it with a multidimensional array.

*edit, yea 2d array would do it too: https://docs.yoyogames.com/source/d.../001_gml language overview/401_06_arrays.html
 
G

Guest User

Guest
Parenting is how I will do it

You can put the instances in the same layer and use layer_get...
layer_get_all_elements(layer_id)
layer_id The unique ID value of the layer to get the elements from (or the layer name as a string)
Array (1D, populated with Element IDs)

var a = layer_get_all_elements(layer);
for (var i = 0; i < array_length_1d(a); i++;)
{
do something
}
 
L

Loïc Mouton

Guest
Wow ! So much good ideas ! I will try all of your answer and i'll tell you if i've found what i want !

Thanks all !
 
L

Loïc Mouton

Guest
The answer of Tailbit is my favorite. Thanks for your answer ! Bye !
 
Top