Scheduler
Defined in: src/scheduler.ts:167
The starting point of a game made with Toucan.
Methods
Section titled “Methods”run():
this
Defined in: src/scheduler.ts:230
Synchronously builds all initially registered plugins (user-defined first), and then bootstraps the engine to run all systems on their respective phases.
Systems and plugins scheduled dynamically after the scheduler is already running will
be picked up automatically on the next frame (with the exception of the STARTUP phase,
which only fires once during this method call).
Returns
Section titled “Returns”this
usePlugin()
Section titled “usePlugin()”usePlugin<
Args>(plugin, …args):this
Defined in: src/scheduler.ts:217
Schedules a plugin to be built, passing it the scheduler itself and the provided arguments.
Reflection
Section titled “Reflection”Plugins are entities with the standard Plugin component, thus, they can be
queried and manipulated like any other entity in Toucan.
Plugins scheduled within other plugins are automatically parented to the parent plugin.
Type Parameters
Section titled “Type Parameters”Args extends defined[]
Parameters
Section titled “Parameters”plugin
Section titled “plugin”Plugin<Args>
…Args
Returns
Section titled “Returns”this
Example
Section titled “Example”function updatePhysics(gravity: number) { ... }
function physicsPlugin(scheduler: Scheduler, gravity: number) { scheduler.useSystem(updatePhysics, UPDATE, gravity)}
scheduler() .usePlugin(physicsPlugin, 196.2) .run()useSystem()
Section titled “useSystem()”useSystem<
Args>(system,phase,args?,label?):this
Defined in: src/scheduler.ts:187
Schedules a system to run in the specified phase with the provided arguments.
Reflection
Section titled “Reflection”Systems are entities with the standard System component, thus, they can be
queried and manipulated like any other entity in Toucan.
Systems scheduled within plugins are automatically parented to the plugin.
Type Parameters
Section titled “Type Parameters”Args extends defined[]
Parameters
Section titled “Parameters”system
Section titled “system”System<Args>
Args
label?
Section titled “label?”string
Returns
Section titled “Returns”this
Example
Section titled “Example”function fireGun(params: RaycastParams) { ... }
scheduler() .addSystems(UPDATE, [fireGun], new RaycastParams()) .run()