1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

events priority

Discussion in 'Programming' started by Heavybrush, Jul 12, 2016.

  1. Heavybrush

    Heavybrush Member

    Joined:
    Jul 6, 2016
    Posts:
    53
    does someone know what is the priority between events??
    1 - creation code
    ...
    x - begin step event
    ...
    x - step event
    ...
    x - end step event
    ... ?

    I have in particular some problem understanding the priority between step events and draw events
    but for sure a guide with all the priorities can help really better

    thanks
     
  2. PlayLight

    PlayLight Guest

  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,143
    Generally, the order of events that you'd need to care about are as listed in that link PlayLight shared. There are some additional things to be aware of, though.

    Alarms, timelines, and I/O (keyboard, mouse, gamepad) checks are applied between the Begin Step and Mid Step events.

    The kinetic variables (speed, hspeed, vspeed) are applied to x and y coordinates between the Mid Step and End Step events.

    Image variables are updated between the End Step and the Begin Draw events.

    As for the orders of things like which key is processed first, I think it's based on the values of the virtual keys. But, seeing as how the I/O gets cleared waaaay too easily in GMS, I can't tell for sure. If i hold two keys down at once, it clears the I/O and stops registering either key for me, even with an asynchronous message.

    Edit: Based on mouse tests, it seems to iterate through all values until it finds one. Supposedly popups like show_message or show_message_async cause I/O handling errors... I got key combos to work after I deleted the show_message calls.
     
    Last edited: Jul 12, 2016
    Heavybrush likes this.
  4. Aura

    Aura Guest

    Also please note that the exact order that the events are going to occur in each step cannot be clearly stated, simply because it depends on the internal workings of GameMaker: Studio, which is subject to change as the software develops. But as the Manual states, there are some events that will always be run in the same order.
     
  5. Heavybrush

    Heavybrush Member

    Joined:
    Jul 6, 2016
    Posts:
    53
    thanks guys
    yes game maker studio provides a set of events and yes it updates a lot
    but, the fundation is never changed but some obsolete scripts
    the only thing is that also the game maker guide doesn't give an appropriate description about all the events and their priority between them
    the answer that I was looking for is one like TheouAegis sayd
    because for instance, I have to match some scripts between the step, begin step, end step, draw, draw begin and draw end
    it's obvious that creation event come before all, but what if I code a complicated thing that need all those events together??
     
  6. Aura

    Aura Guest

    You could always use show_debug_message() in each event to determine the exact order they are run in. And since you can't change the order of the events as they rely on internal workings of the software, there is no point of trying to make them (events that already don't run together) run together.
     
    Bentley likes this.
  7. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,143
    Careful, there. It's also important to remember that most of the events are global events; that is, events like Room Start, Step, Draw, and I/O handles and all of those fun in-betweeners like alarm and timeline handles occur at the same time for all instances (in order). So if you created 5 instances of an object and set alarm[0] for all 5 instances at the same time, all 5 instances will fire off their alarm events at the same time, rather than instance 1 firing off its alarm then handling its step, then instance 2 firing off its alarm then handling its step; in other words, it's instance 1 fires off its alarm then instance 2 fires off its alarm and so on, then it moves on to the Step event.

    Also, the Create Event is handled before everything because it's not really an event per se, but a subroutine that is called every time an instance is created. The same is true of other similar events like Destroy and whatnot. Those events are handled immediately as interrupts within whatever global event is currently running. In other words, creating an instance during another instance's End Step event will cause the new object to miss out on the Begin Step, Mid Step, in-betweeners, and speed updates, but it will still get its image variables updated.

    UPDATE
    Also, creating an instance during the End Draw event will cause it to skip its drawing, so it won't be visible for the first frame (no surprise there). What that also means is the image variables will be updated before it's ever drawn. How is this pertinent to anything? Well, if you want to, say, clone certain old video games like, oh, Castlevania III which increases the image frame before they're first drawn, you'd have to have your enemy spawners create them during the End Draw event.
     
    Last edited: Jul 12, 2016
    Heavybrush and anomalous like this.
  8. Heavybrush

    Heavybrush Member

    Joined:
    Jul 6, 2016
    Posts:
    53
    thank you very much
    I really appreciate your help :)
     

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