1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

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

Discussion in 'Programming' started by Loïc Mouton, Nov 7, 2019 at 7:38 PM.

Tags:
  1. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    8
    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 !
     
  2. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    56
    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
     
  3. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    49
    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
     
  4. Guest User

    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
    }
     
  5. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    8
    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 !
     
  6. Loïc Mouton

    Loïc Mouton Member

    Joined:
    Sep 13, 2019
    Posts:
    8
    The answer of Tailbit is my favorite. Thanks for your answer ! Bye !
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice