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

Method worldToLocal

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

* convert the given world coordinates into "local" (screen) coordinates * @param x - the x world coordinate to be converted * @param y - the y world coordinate to be converted * @param [v] - an optional vector object where to set the converted value * @returns a vector with the converted loc

(x: number, y: number, v?: Vector2d)

Source from the content-addressed store, hash-verified

889 * @returns a vector with the converted local coordinates
890 */
891 worldToLocal(x: number, y: number, v?: Vector2d): Vector2d {
892 v = v || vector2dPool.get();
893 v.set(x, y);
894 if (!this.currentTransform.isIdentity()) {
895 this.currentTransform.apply(v);
896 }
897 return v.sub(this.pos).add(game.world.pos);
898 }
899
900 /**
901 * Build and install the world + screen projections used when this

Callers 2

camera.spec.jsFile · 0.80
pointerMoveMethod · 0.80

Calls 6

getMethod · 0.65
setMethod · 0.45
isIdentityMethod · 0.45
applyMethod · 0.45
addMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected