* 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)
| 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 |