Always or Every (time) conditions
Author: | Muz
|
Submitted: | 4th May, 2005
|
Views: | 6061
| Rated: |
|
|
Time for a quick article .
Why use?
Everyone uses either the always event or the timers to run something repeatedly. The question is... which one should you use?
Always
The Always condition runs the event EVERY 'tick'. Thus, it just repeats itself all the time. It requires almost no system resources, thus it's almost harmless in itself.
However, it'll ALWAYS run the event, meaning that if the event uses high system resources, then your game will be a lot slower.
Timers
The Every (insert time here) actually uses some system resources, according to a test I did some while ago. Below 0.03 seconds, it actually works at about the same rate. Thus an event set to Every 0.01 seconds is the same as an event that runs Every 0.02 seconds.
Every ___ conditions actually use more resources in themselves, but as they execute the events less often, they might actually use less resources overall.
Which one again?
Point of this boring article is...
Use the Always condition if the event being repeated is a low-resource one and you want to be used all the time. It's also good if you need to 'reset' something simple.
For example, Always -> Set flag 2 to 0.
Use the Every condition if you don't need the event repeated all the time, or the action would take a lot of resources.
E.g, Every 0.04 s -> Center screen on (sprite).
Every 0.03 s -> Set Y("Active") to Sin(X("Active")).
Every 0.1 s -> Set Alterable Value A to Sqr((X("Active")-X("Active 2"))*(X("Active")-X("Active 2"))+(Y( "Active")-Y("Active 2"))*(Y("Active")-Y("Active 2")))
You also shouldn't use Every 0.02 s or Every 0.01 s as both of them are pointless and simply take up more resources. Stick to a minimum of Every 0.03 seconds.
|
|
|