UNPKG

modern-canvas

Version:

A JavaScript WebGL rendering engine. only the ESM.

30 lines (29 loc) 1.19 kB
import type { CoreObjectEvents } from '../object'; import { CoreObject } from '../object'; export interface MainLoopEvents extends CoreObjectEvents { process: [delta: number]; } export interface MainLoop { on: <K extends keyof MainLoopEvents & string>(event: K, listener: (...args: MainLoopEvents[K]) => void) => this; once: <K extends keyof MainLoopEvents & string>(event: K, listener: (...args: MainLoopEvents[K]) => void) => this; off: <K extends keyof MainLoopEvents & string>(event: K, listener: (...args: MainLoopEvents[K]) => void) => this; emit: <K extends keyof MainLoopEvents & string>(event: K, ...args: MainLoopEvents[K]) => this; } export interface MainLoopProperties { fps: number; speed: number; } export declare class MainLoop extends CoreObject { fps: number; speed: number; protected _starting: boolean; protected _nextDeltaTime: number; protected _startedProcess?: (delta: number) => void; get starting(): boolean; get spf(): number; constructor(properties?: Partial<MainLoopProperties>); start(process: (delta: number) => void): void; stop(): void; protected _onTicker(): void; destroy(): void; }