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

Method setDeadzone

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

* change the deadzone settings. * the "deadzone" defines an area within the current camera in which * the followed renderable can move without scrolling the camera. * @see follow * @param w - deadzone width * @param h - deadzone height

(w: number, h: number)

Source from the content-addressed store, hash-verified

453 * @param h - deadzone height
454 */
455 setDeadzone(w: number, h: number): void {
456 if (typeof this.deadzone === "undefined") {
457 this.deadzone = new Rect(0, 0, 0, 0);
458 }
459
460 // reusing the old code for now...
461 this.deadzone.pos.set(
462 ~~((this.width - w) / 2),
463 ~~((this.height - h) / 2 - h * 0.25),
464 );
465 this.deadzone.resize(w, h);
466
467 this.smoothFollow = false;
468
469 // force a camera update
470 this.updateTarget();
471
472 this.smoothFollow = true;
473 }
474
475 /**
476 * resize the camera

Callers 5

constructorMethod · 0.95
resizeMethod · 0.95
camera.spec.jsFile · 0.80
runOneFrameFunction · 0.80
simulateFunction · 0.80

Calls 3

updateTargetMethod · 0.95
setMethod · 0.45
resizeMethod · 0.45

Tested by 2

runOneFrameFunction · 0.64
simulateFunction · 0.64