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

Method update

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

@ignore

(dt?: number)

Source from the content-addressed store, hash-verified

655
656 /** @ignore */
657 override update(dt?: number): boolean {
658 // update the camera position
659 this.updateTarget(dt);
660
661 // update all active camera effects
662 if (this.cameraEffects.length > 0) {
663 for (const fx of this.cameraEffects) {
664 fx.update(dt ?? 0);
665 }
666 // remove completed effects
667 for (let i = this.cameraEffects.length - 1; i >= 0; i--) {
668 if (this.cameraEffects[i].isComplete) {
669 this.cameraEffects[i].destroy();
670 this.cameraEffects.splice(i, 1);
671 }
672 }
673 this.isDirty = true;
674 }
675
676 if (this.isDirty) {
677 //publish the corresponding message
678 emit(VIEWPORT_ONCHANGE, this.pos);
679 }
680
681 if (!this.currentTransform.isIdentity()) {
682 this.invCurrentTransform.copy(this.currentTransform).invert();
683 } else {
684 // reset to default
685 this.invCurrentTransform.identity();
686 }
687
688 return super.update(dt ?? 0);
689 }
690
691 /**
692 * shake the camera

Callers 2

resizeMethod · 0.95
setBoundsMethod · 0.95

Calls 7

updateTargetMethod · 0.95
emitFunction · 0.90
destroyMethod · 0.65
isIdentityMethod · 0.45
invertMethod · 0.45
copyMethod · 0.45
identityMethod · 0.45

Tested by

no test coverage detected