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

Method resize

packages/melonjs/src/camera/camera2d.ts:481–506  ·  view source on GitHub ↗

* resize the camera * @param w - new width of the camera * @param h - new height of the camera * @returns this camera

(w: number, h: number)

Source from the content-addressed store, hash-verified

479 * @returns this camera
480 */
481 override resize(w: number, h: number): this {
482 // skip resize for non-auto-resize cameras (e.g. minimap, split-screen)
483 if (!this.autoResize) {
484 return this;
485 }
486
487 // parent consctructor, resize camera rect
488 super.resize(w, h);
489
490 // disable damping while resizing
491 this.smoothFollow = false;
492
493 // reset everything
494 this.setBounds(0, 0, w, h);
495 this.setDeadzone(w / 6, h / 6);
496 this.update();
497 this.smoothFollow = true;
498
499 // update the projection matrix
500 this._updateProjectionMatrix();
501
502 // publish the viewport resize event
503 emit(VIEWPORT_ONRESIZE, this.width, this.height);
504
505 return this;
506 }
507
508 /**
509 * set the camera boundaries (set to the world limit by default).

Callers 2

setViewportMethod · 0.45
setDeadzoneMethod · 0.45

Calls 5

setBoundsMethod · 0.95
setDeadzoneMethod · 0.95
updateMethod · 0.95
emitFunction · 0.90

Tested by

no test coverage detected