Hello,
I was reading some tutorials and find the advanced tips and tricks from Whiteclaws
After the read, I learned something ugly of my point of vision, as a non programmer and a common user of C2.
ait 0 Seconds
Wait 0 seconds is designed to postpone until the end of the current run of events (not even the next tick - the same tick, but after all other events).
Explanation :
Condition 1
.. Event1
.. Event2
In this case , event 1 & event 2 will occur in the same tick
Condition 1
.. Event1
.. Wait 0 seconds
.. Event2
Putting a 0 seconds will insure that Event2 will only occur after Event1 is finished
Some examples ...
On start of layout
.. Create Object1
.. Set Variable1 to 0
Here , the two events occur in the same tick , meaning the object is created in the same moment as the variable is changed , The object isn't ready , so the variable is assigned before the object is created ... Doesn't work .
If you place "Wait 0 seconds" between the two , C2 will spawn the instance , wait until it is ready , and then assign the variable
This trick is very useful when you need to call a function then call another depending on the result of the last one ...
scirra.com/tutorials/510/advanced-tips-and-tricks-that-construct2-offers
I always believed C2 did the actions in sequence, without the necessity of waiting 0, also, I never saw a code using the wait 0 before, but if it's true, all my job will need to be redone, without the mention of my pupils =
Ashley , do you can clarify if it's really necessary or just a "best practice" or C2 already do the actions in sequence?
That's annoying create an object on the canvas, like an enemy, where you want setup his sine behavior to meet the route you wanted, and all this event run at same time, what could be a mess and/or miss the sine configuration to that specific object and/or shuffle it with another object spawned on the same event.
Thank you for any advice!