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

Method constructor

packages/debug-plugin/src/index.js:38–134  ·  view source on GitHub ↗

* @param {number} [debugToggle=input.KEY.S] - a default key to toggle the debug panel visibility state * @see input.KEY for default key options

(debugToggle = input.KEY.S)

Source from the content-addressed store, hash-verified

36 * @see input.KEY for default key options
37 */
38 constructor(debugToggle = input.KEY.S) {
39 super();
40
41 // Minimum melonJS version — `Renderable.postDraw` now reads the
42 // `PhysicsAdapter.getBodyAABB` / `getBodyShapes` debug API
43 // added in 19.5. Older releases don't expose those methods and
44 // the patch would silently skip drawing physics overlays.
45 this.version = "19.5.0";
46
47 console.log(`${name} ${version} | ${homepage}`);
48
49 this.debugToggle = debugToggle;
50
51 this.counters = new Counters([
52 "shapes",
53 "sprites",
54 "velocity",
55 "bounds",
56 "children",
57 "draws",
58 ]);
59
60 this.visible = false;
61
62 // checkbox state
63 const hash = utils.getUriFragment();
64 this.options = {
65 hitbox: hash.hitbox || false,
66 velocity: hash.velocity || false,
67 quadtree: hash.quadtree || false,
68 };
69
70 // frame time history for the sparkline graphs
71 this.updateHistory = new Float32Array(GRAPH_SAMPLES);
72 this.drawHistory = new Float32Array(GRAPH_SAMPLES);
73 this.memHistory = new Float32Array(GRAPH_SAMPLES);
74 this.historyIndex = 0;
75
76 // register the web font / CSS and build the HTML overlay
77 registerStyles();
78 this.panel = null;
79 this.panelWrap = null;
80 this.stats = {};
81 this._buildPanel();
82
83 // frame timing
84 this.frameUpdateStartTime = 0;
85 this.frameDrawStartTime = 0;
86 this.frameUpdateTime = 0;
87 this.frameDrawTime = 0;
88
89 // event listener references for cleanup
90 this._onResize = () => {
91 this._syncPosition();
92 };
93 this._onBeforeUpdate = (time) => {
94 this.frameUpdateStartTime = time;
95 };

Callers

nothing calls this directly

Calls 10

_buildPanelMethod · 0.95
_syncPositionMethod · 0.95
_updatePanelMethod · 0.95
_drawQuadTreeMethod · 0.95
toggleMethod · 0.95
showMethod · 0.95
registerStylesFunction · 0.90
applyPatchesFunction · 0.90
onMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected