gdmp.time
이 콘텐츠는 아직 번역되지 않았습니다.
| Call | What it does |
|---|---|
now() |
milliseconds on this host’s clock (monotonic) |
after(ms, fn) → id |
run fn once, ms from now |
every(ms, fn) → id |
run fn every ms |
cancel(id) → bool |
stop a timer |
onTick(fn) |
fn({now, dt}) on every engine tick (the server: ~30 / s; a client: every game frame batch): now = now(), dt = milliseconds since the previous tick |
TypeScript
Section titled “TypeScript”The declarations from the GDMP types (namespace GDMP), comments included:
interface Time { /** Milliseconds on this host's monotonic clock. */ now(): number; after(ms: number, fn: () => void): TimerId; every(ms: number, fn: () => void): TimerId; cancel(id: TimerId): boolean; /** On every engine tick (the server ~30 / s; a client every game frame batch): `now` = `gdmp.time.now()`, * `dt` = milliseconds since the previous tick. */ onTick(fn: Callback<[tick: { readonly now: number; readonly dt: number }]>): void;}