MCPcopy Create free account
hub / github.com/melonjs/melonJS / constructor

Method constructor

packages/melonjs/src/system/timer.ts:41–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39 timerId: number;
40
41 constructor() {
42 /**
43 * Last game tick value. <br>
44 * Use this value to scale velocities during frame drops due to slow hardware or when setting an FPS limit.
45 * This feature is disabled by default (Enable interpolation to use it).
46 * @see interpolation
47 */
48 this.tick = 1.0;
49
50 /**
51 * Last measured fps rate.<br>
52 * This feature is disabled by default, unless the debugPanel is enabled/visible.
53 */
54 this.fps = 0;
55
56 /**
57 * Set the maximum target display frame per second
58 * @see tick
59 * @default 60
60 */
61 this.maxfps = 60;
62
63 /**
64 * Enable/disable frame interpolation
65 * @see tick
66 * @default false
67 */
68 this.interpolation = false;
69
70 //hold element to display fps
71 this.framecount = 0;
72 this.framedelta = 0;
73
74 /* fps count stuff */
75 this.last = 0;
76 this.now = 0;
77 this.delta = 0;
78 // for timeout/interval update
79 this.step = 0;
80 this.minstep = 0;
81
82 // list of defined timer function
83 this.timers = [];
84 this.timerId = 0;
85
86 // Initialize timer on Boot event
87 once(BOOT, () => {
88 // reset variables to initial state
89 this.reset();
90 this.now = this.last = 0;
91 // register to the game before update event
92 on(GAME_BEFORE_UPDATE, (time) => {
93 this.update(time);
94 });
95 });
96
97 // reset timer
98 on(STATE_RESUME, () => {

Callers

nothing calls this directly

Calls 4

resetMethod · 0.95
updateMethod · 0.95
onceFunction · 0.90
onFunction · 0.90

Tested by

no test coverage detected