kunpolibrary/src/global/InnerTimer.ts

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-02-20 11:27:28 +08:00
/**
* @Author: Gongxh
* @Date: 2025-02-14
* @Description: 使
*/
import { Timer } from "../tool/timer/Timer";
export class InnerTimer {
private static _timer: Timer = null;
/**
* 16
* 便
*/
public static initTimer(): void {
this._timer = new Timer(16);
}
/**
*
* @param callback -
* @param interval -
* @param loop - [loop=0] 01~nn次-1
* @returns ID
*/
public static startTimer(callback: () => void, interval: number, loop: number = 0): number {
return this._timer.start(callback, interval, loop);
}
/**
* ID的计时器
* @param timerId -
*/
public static stopTimer(timerId: number): void {
this._timer.stop(timerId);
}
public static update(dt: number): void {
this._timer?.update(dt);
}
}