SOLVED Is it possible to change the order of handling of instances due to each other?

Discussion in 'Programming' started by ghostinecatnewyear, Feb 11, 2019.

Tags:
  1. ghostinecatnewyear

    ghostinecatnewyear Member

    Joined:
    Jan 5, 2018
    Posts:
    8
    Hello everyone! You know that instances are handled in order due to order of their creation. For example the instance "A" has been created and then the instance "B" has been created. Each step the A's code will be executed firstly and only then the B's one. So I want to know wether it's possible to do so the B's code is executed firstly and only then the A's.
     
  2. DukeSoft

    DukeSoft Member

    Joined:
    Jun 20, 2016
    Posts:
    769
    Yes, the depth of the instance does that (goes from highest depth (furthest away) to lowest (closest to you)). Also you have the 'Before Step" and "After Step" events to change some ordering.
     
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,627
    What version of GMS are you using?

    In GMS1:
    In other words, make object B object A.
     
  4. ph101

    ph101 Member

    Joined:
    Jun 20, 2016
    Posts:
    415
    Or in other other words, move the object you want to execute first (talking step event not draw event here ) to the top of the resource tree and the one you want to execute last to the bottom.
     
  5. dannyjenn

    dannyjenn Member

    Joined:
    Jul 29, 2017
    Posts:
    568
    There used to be a way to disable the events, such that you could have a single controller object which called all the events in all the other objects. By doing that, you could have full control over the order. But I highly doubt you can still do this in GMS2.

    I'm pretty sure that that was only true of the draw event, not the other events. And I don't think it's true at all anymore, since GMS2 replaced the depth system with the layer system.
     
  6. immortalx

    immortalx Member

    Joined:
    Sep 6, 2018
    Posts:
    296
    @ghostinecatnewyear are you talking about different objects, or different instances of the same object? If it's the latter, I guess an easy way to do that is, the moment you need instance B to run its code first, destroy instance A and "re-create" it. It will get assigned a greater id and if I'm not mistaken its step-event code will get executed after instance B from then on.
     

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