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

Method reset

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

* reset the camera position to specified coordinates * @param [x=0] - initial position of the camera on the x axis * @param [y=0] - initial position of the camera on the y axis

(x: number = 0, y: number = 0)

Source from the content-addressed store, hash-verified

413 * @param [y=0] - initial position of the camera on the y axis
414 */
415 reset(x: number = 0, y: number = 0): void {
416 // reset the initial camera position to 0,0
417 this.pos.x = x;
418 this.pos.y = y;
419
420 // reset the target
421 this.unfollow();
422
423 // damping default value
424 this.smoothFollow = true;
425 this.damping = 1.0;
426
427 // reset the transformation matrix
428 this.currentTransform.identity();
429 this.invCurrentTransform.identity().invert();
430
431 // reset the projection matrices
432 this.worldProjection.identity();
433 this.screenProjection.identity();
434
435 // update the projection matrix
436 this._updateProjectionMatrix();
437
438 // remove non-persistent camera effects (persistent ones survive state changes)
439 for (let i = this.cameraEffects.length - 1; i >= 0; i--) {
440 if (!this.cameraEffects[i].isPersistent) {
441 this.cameraEffects[i].destroy();
442 this.cameraEffects.splice(i, 1);
443 }
444 }
445 }
446
447 /**
448 * change the deadzone settings.

Callers 1

drawMethod · 0.45

Calls 5

unfollowMethod · 0.95
destroyMethod · 0.65
identityMethod · 0.45
invertMethod · 0.45

Tested by

no test coverage detected