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

Method constructor

packages/melonjs/src/application/application.ts:246–274  ·  view source on GitHub ↗

* Create and initialize a new melonJS Application. * This is the recommended way to start a melonJS game. * @param width - The width of the canvas viewport * @param height - The height of the canvas viewport * @param options - The optional parameters for the application and default renderer

(
		width: number,
		height: number,
		options: Partial<ApplicationSettings> & { legacy?: boolean } = {},
	)

Source from the content-addressed store, hash-verified

244 * });
245 */
246 constructor(
247 width: number,
248 height: number,
249 options: Partial<ApplicationSettings> & { legacy?: boolean } = {},
250 ) {
251 this.mergeGroup = true;
252 this.lastUpdate = 0;
253 this.isInitialized = false;
254 this.pauseOnBlur = true;
255 this.resumeOnFocus = true;
256 this.stopOnBlur = false;
257 this.isDirty = true;
258 this.isAlwaysDirty = false;
259 this.frameCounter = 0;
260 this.frameRate = 1;
261 this.accumulator = 0.0;
262 this.accumulatorMax = 0.0;
263 this.accumulatorUpdateDelta = 0;
264 this.stepSize = 1000 / 60;
265 this.updateDelta = 0;
266 this.lastUpdateStart = null;
267 this.updateAverageDelta = 0;
268
269 // when using the default game application, legacy is set to true
270 // and init is called through the legacy video.init() call
271 if (options.legacy !== true) {
272 this.init(width, height, options);
273 }
274 }
275
276 /**
277 * init the game instance (create a physic world, update starting time, etc..)

Callers

nothing calls this directly

Calls 1

initMethod · 0.95

Tested by

no test coverage detected