Skip to content

scheduler

scheduler(): Scheduler

Defined in: scheduler/scheduler.ts:487

Returns a new Scheduler, the starting point of a game made with Toucan.

It is responsible for running systems, building plugins and configuring system sets.

Scheduler

Only one scheduler can exist at a time. Calling scheduler() multiple times will throw an error.

const Person = component()
const Age = component<number>()
function spawnPeople() {
entity('Alice').set(Age, 25)
entity('Bob').set(Age, 30)
}
const greetPeople = query(Age).with(Person).bind((entity, age) => {
print(`Hello, ${entity}! I can magically sense that you're ${age} years old!`)
})
scheduler()
.useSystem('startup', spawnPeople)
.useSystem('update', greetPeople)
.run()