Hello All ,
I'm here to teach you some of the most advanced techniques you can find in C2 ...
You'll find those very useful because they can have the potential to drastically reduce the numbers of events you may need to make a game ...
Now that I took your attention , let's get started , shall we ?
Note \\ If you find any errors in the text , feel free to correct me
Wait 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).
In this case , event 1 & event 2 will occur in the same tick
.. Wait 0 seconds
Putting a 0 seconds will insure that Event2 will only occur after Event1 is finished
Some examples ...
On start of layout
.. Destroy Object1
.. Set Variable1 to Object1.Count
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 destroyed yet , so the variable is assigned before the object count is egal to zero ... Doesn't work .
If you place "Wait 0 seconds" between the two , C2 will destroy the instance , wait until it is successfully destroyed , and then assign the variable , in this case , set it to 0 ...
This trick is very useful when you need to call a function then call another depending on the result of the last one ...
Calling an event when a loop is finished
To verify if a loop i finished , many users set variables an complicate their lives ... I found a very useful trick in the event system that can help you determinate if a loop is finished or not ...
Event run in order from top to bottom , and sub-events also run in order from top to bottom , and if there are many sub-event , one may only run if the other already finished ...
Top level event
.. Your event that will execute after the loop
This trick can be used after any loop ... some of the uses ...
... For every element X/Y
---- Current Value = 1 ; Create object1 at (CurX,CurY)
... Every tick ; Destroy Object1
Power of Functions
You may know this one but I always highly recommend it , use functions ...
Combined with the tips I taught you not a long ago ... the Functions Real Power is unleashed ...
--> This will Happen!
That's all for today folks , I hope you learned , if you did , click that star and help other people find this tutorial ...
See you soon !