Skip to main content

Scheduler

Description:

  A scheduler that manages the execution of scheduled tasks.

Class Object: Scheduler Class.

Inherits from: Object.

timeScale

Type: Field.

Description:

  The time scale factor for the scheduler. This factor is applied to deltaTime that the scheduled functions will receive.

Signature:

timeScale: number

fixedFPS

Type: Field.

Description:

  The target frame rate (in frames per second) for a fixed update mode. The fixed update will ensure a constant frame rate, and the operation handled in a fixed update can use a constant delta time value. It is used for preventing weird behavior of a physics engine or synchronizing some states via network communications.

Signature:

fixedFPS: integer

schedule

Type: Function.

Description:

  Schedules a function to be called every frame.

Signature:

schedule: function(self: Scheduler, handler: function(number): boolean)

Parameters:

ParameterTypeDescription
handlerfunctionThe function to be called.
It should take a single argument of type number, which represents the delta time since the last frame.
If the function returns true, it will not be called again.

schedule

Type: Function.

Description:

  Schedules a coroutine job to be resumed every frame.

Signature:

schedule: function(self: Scheduler, job: Routine.Job)

Parameters:

ParameterTypeDescription
jobRoutine.JobThe coroutine job to be resumed.

update

Type: Function.

Description:

  Manually updates the scheduler if it is created by the user.

Signature:

update: function(self: Scheduler, deltaTime: number): boolean

Parameters:

ParameterTypeDescription
deltaTimenumberThe time interval since the last update.

Returns:

Return TypeDescription
booleanReturns true if the scheduler has stopped.