Tutorial: basic use - kemonologic/fuwafuwa GitHub Wiki
Basic use
Creating a timer
fuwafuwa was created to be a simple timer system that could be as easy to use as alarms. As a result, it can be used with as little code as the following (after initial setup)
Create event
myTimer = timer_create(1000);
Step event
if (timer_check(myTimer)){
show_debug_message("Wow! The power of science is amazing!");
}
This will print a message after 1000 milliseconds (1 second) have passed in real-time.
Specifying a unit
You can also specify a unit instead of the default milliseconds, to make things easier. If you set a unit here, all further interaction with the timer will be in that unit.
Create event
myTimer = timer_create(1,time.s);
Other units are available, such as framelocked units (that run in terms of game time rather than real-world time). See the entry for timer_create for more information.
Autodestroy
By default, fuwafuwa automatically destroys (garbage collects) timers that were created by instances that no longer exist: this is called autodestroy.
If you'd prefer not to use this feature for a particular timer, simply set the last argument of timer_create to false, and then destroy the timer yourself in the Cleanup or Destroy event of your object.
Create event
myTimer = timer_create(1000,time.ms,false);
Destroy/Cleanup event
timer_destroy(myTimer);
myTimer = undefined;