Left Click Trigger - Events Order

0 favourites
  • 10 posts
From the Asset Store
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • Hi all, I suspect nobody will know the answer to this unless I tag Ashley, but will try asking anyway...

    I have found something that seems wrong to me, but I did some testing and discovered it was wrong in Construct 2 as well, so I don't want to file a submit a bug if it's 'working as designed'.

    If I have 2 events like this:

    #1 On Left Button Clicked AND Cursor Over Sprite -> Action 1

    #2 On Left Button Clicked -> Action 2

    Then when I click on the Sprite, Action 1 runs before Action 2 as expected.

    However, if I do this:

    #1 On Left Button Clicked on Sprite -> Action 1

    #2 On Left Button Clicked -> Action 2

    Then clicking on the Sprite causes Action 2 to run before Action 1

    These are two methods of achieving the same thing, and my expectation would be that both these examples should run the same, with Action 1 coming before Action 2.

  • Those aren't the same conditions though. On button clicked is totally separate from On button clicked on Sprite. I would fully expect that the engine would call all On button clicked triggers first, and then move on to On button clicked on Sprite.

    Remember, triggers are called outside of the event sheet. You shouldn't make assumptions about the order of two separate triggers.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think what you said is probably true, it was kind of the answer I was expecting. I have been using C2/C3 for a long time but wanted to make sure I went back to basics before I asked this. So I went back and read the manual, and the only thing that the official documentation states is this:

    the ordering of triggers relative to other events is not important (except relative to other triggers of the same type, since triggers still fire top-to-bottom)

    So I think the documentation is supporting your answer, that triggers of the same type fire top to bottom. To me though, anything triggered by a left click is the same type, but others may take a different view (and I can see that I'm probably wrong).

    My issue really is that all this stuff is hidden, there is nothing to tell me the order of execution for various triggers. If the engine runs certain triggers before others then that's fine, but surely that is information that should be made available to me? After 7+years it's the only thing that I still really struggle with - certain triggers, behaviours etc running in an order unknown to me. I'm happy to design around anything if I just know the rules.

  • Also the outcome is kind of thin because I'm not sure how you can get into too much trouble if an 'on any click' triggers in the same tick but earlier than 'on clicked on an object'.

  • it actually caused me a huge headache, as clicking on a certain object (a menu button) ran the function to pause the game. The left click was used in some of the in-game controls, but those events only fired if the game was not paused. So I found that when clicking the pause button some events were running during the pause that shouldn't have been, and when you unpaused the game a load stuff happened that should not have happened. I got round it, but as I said I'm more frustrated by not being able to find out this stuff from the documentation.

  • You've trapped yourself by having a game where any click does something but also clicking a pause button counts as any click. You can get around this by having conditions like 'on any click and cursor is not over pause button' but I see your point.

  • You can get around this by having conditions like 'on any click and cursor is not over pause button'

    Exactly what I did! Yeah I'm not angry or anything, appreciate the replies. I just remember using Gamemaker there was a list provided of the exact order of things, like events, scripts, movements, physics, rendering the screen etc. I much prefer Construct but that level of info was super useful.

  • Those aren't the same conditions though. On button clicked is totally separate from On button clicked on Sprite. I would fully expect that the engine would call all On button clicked triggers first, and then move on to On button clicked on Sprite.

    This is correct.

    The order of triggers is actually pretty complicated, especially if you start bringing in things like triggers in sub-events and triggers via included event sheets. I'd recommend wherever possible avoiding depending on the order the engine fires triggers, especially since it's not clear from looking at an event sheet what the ordering really is. Generally you can do this by just using a single trigger event to do everything in one set of actions/sub-events, so you can clearly see the order things are done within that event.

  • Thanks for the reply Ashley, just doing some testing last night revealed that it's relatively few cases when this is a problem. There are a small number of triggers that fire multiple things - mouse clicks, key presses and animation finishing. I think my testing helped me understand them. Have I missed anything in the documentation that explains the order of things outside events? I always wondered if the various movement behaviours ran before or after events each tick.

  • The specific ordering in the engine is very complicated, varies depending on the feature, occasionally changes, and is the type of thing people really should avoid depending on if they can, so it's not documented.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)