A downloadable asset pack

Download NowName your own price

[INFORMATION]

This is yet another task scheduler (advanced timers) system asset for GMS2.3+.

[QUICK GUIDE]

1) You need to instantiate a Scheduler, using the following code:

scheduler = new Scheduler();

2) Schedule a event to be executed after an amount of time, X seconds...

myEvent = scheduler.scheduleOnce(function() {
    show_debug_message("Done");
}, 3.5);

3) Finally during step event we need to call the scheduler update method (passing the delta_time constant).

scheduler.update(delta_time);

4) Run the game and after 3.5 seconds you should see the message "Done" printed to the terminal.

[MANUAL]

This library provides a set of useful function that you can use to create time based (fps independent) events.

scheduler = new Scheduler();
   
// Resume the scheduler if it was paused
scheduler.resume()
   
// Pauses the scheduler if it is running
scheduler.pause()
   
// Updates the scheduler
scheduler.update(delta_time)
   
// Schedules an event with a callback function
event = scheduler.scheduleOnce(callback, timeout)
   
// Schedules a looping event with a callback function
event = scheduler.scheduleInterval(callback, timeout)
  
// Creates a trigger for scheduling events (*)
trigger = scheduler.createTrigger(callback, timeout, loop, releaseRef)
  
// Unschedule a given event or a given method (optional all flag)
event = scheduler.unschedule(event/method, all?)

(*) The createTrigger method should be highlighted since it provides a powerful way of scheduling events. This method returns a trigger and this trigger can be called as a method returning an event:

event = trigger(); // Triggers the schedule of an event.
  
//Trigger is duplicate safe, meaning that consecutive calls will NOT schedule multiple events.

The event instance itself provides a set of utility functions that can be used to manipulate the event after it was scheduled:

// Cancels the current scheduled event
event.cancel()
   
// Returns true if the event is schedule to execute
event.isScheduled()
    
// Returns the callback method associated with the event
event.getCallback()

All the code is fully documented as always with my assets, so you shouldn't have any problems following along and understanding the implementation.

[NOTES]

The demo project serves as an example for the Scheduler system and all its code is inside the Demo folder of the asset pack. You don't need to include it to use the asset.

[COMPATIBILITY]

The asset is fully compatible with GMS2.3+ and is purely written in GML making it compatible with all exports available.

Download

Download NowName your own price

Click download now to get access to the following files:

xScheduler.yymps 9 kB

Leave a comment

Log in with itch.io to leave a comment.