How does Construct handle similar events in the same tick?

For questions about using Classic.

Post » Mon Jun 14, 2010 12:01 pm

Hi all :D

I'm trying to understand how Construct works, and I have a quick question about how Construct handles similar events that occur within the same tick.

Let's say I have two families, Red and Green, and 10 objects in each family.

I have an event set up like this:

-On collision between Red and Green
Action: Set global variable(speedxRED) to Red[physics]VelocityX
Action: Set global variable(speedyRED) to Red[physics]VelocityY
Action: Set global variable(speedxGREEN) to Green[physics]VelocityX
Action: Set global variable(speedyGREEN) to Green[physics]VelocityY

I then use other events to do further calculations with those global variables and apply some actions to the objects that collided.

My question is, if the situation occurs that two independent collisions happen within the same tick, will Construct treat each collision separately, and first store the values in the global variables for one of the collisions, then overwrite them with the values from the other collision? Or will it just be a big mess?

Also, if they are treated separately, will Construct go trough the entire chain of events involving the global variables for one of the collisions, and then do the same with the other collision? Or is there a risk that the other collision will mess up any ongoing calculations that is happening with the first collision?
B
1
G
3
Posts: 4
Reputation: 1,135

Post » Mon Jun 14, 2010 12:30 pm

The events will take place in order. All the calculations for the collision event for all instances will take place before the next condition is evaluated. There shouldn't be a "big mess". I believe that given your scenario, the assignment to the global variable would occur only once using the value of the first picked instance. Don't quote me on that until you test it, which should be simple enough. The first picked instance in the selected object list is not simple to plan for, especially in families with multiple types, so if you need greater control over which object pv gets used add further conditions or subevents. If you would like for each private variable to be used in succession, use a "for each" condition or a "for each ordered" condition which would also allow you to specify the order the objects were acted upon. Also, just to clarify, construct never runs anything concurrently, everything is evaluated and executed top to bottom, except with special cases like "start of layout", loops, and functions
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Jun 14, 2010 3:29 pm

[quote="lucid":2poek834]Also, just to clarify, construct never runs anything concurrently, everything is evaluated and executed top to bottom, except with special cases like "start of layout", loops, and functions[/quote:2poek834]

And just to add to the "start of layout" thing:

Multiple start of layout events will still run in the order of the event sheet. The ones higher on the list will run before the lower start of layout events. Basically anything that has a green arrow next to it is a trigger, which means that it runs when called, but the order still matters when there is multiple identical triggers.

I know you're probably asking about using globals in this situation as a hypothetical situation to learn more about construct, but in case you didn't think of it, private variables would be better in this case. Each collided pair of instances would have their values set accordingly, and you can use subevents to modify the values without losing the picking.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Jun 15, 2010 9:30 am

[quote="lucid":x24jrqz7]All the calculations for the collision event for all instances will take place before the next condition is evaluated.[/quote:x24jrqz7]

That's handy information :D

Thanks guys, I understand it a bit better now :)
B
1
G
3
Posts: 4
Reputation: 1,135


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests