Home > @esengine/ecs-framework-monorepo > Core > schedule
Core.schedule() method
调度定时器
创建一个定时器,在指定时间后执行回调函数。
Signature:
typescript
static schedule<TContext = unknown>(timeInSeconds: number, repeats?: boolean, context?: TContext, onTime?: (timer: ITimer<TContext>) => void): Timer<TContext>;
Parameters
Parameter | Type | Description |
---|---|---|
timeInSeconds | number | 延迟时间(秒) |
repeats | boolean | (Optional) 是否重复执行,默认为false |
context | TContext | (Optional) 回调函数的上下文,默认为null |
onTime | (timer: ITimer<TContext>) => void | (Optional) 定时器触发时的回调函数 |
Returns:
Timer<TContext>
创建的定时器实例