Zoom in and out with the mouse wheel seem to be working. However I want to the throw the mouse position in the mix.
If the user zooms in, the camera would (preferably slowly, but instantly would work also) move towards the mouse position as the as it zooms in or out. In other words the camera should center on the current mouse x,y coords or steer towards it at least, while zooming.
Does the camera x,y not equal canvas x,y? It seems to pan in the opposite direction. I've tried both pan() and centerOn() in my [Typescript] create() method:
this.input.on("wheel", (pointer, gameObjects, deltaX, deltaY, deltaZ) => {
if (deltaY > 0) {
this.camera.zoom -= .1;
}
if (deltaY < 0) {
this.camera.zoom += .1;
}
this.camera.pan(pointer.x, point.y, 2000, "Power2");
//this.camera.centerOn(pointer.x, pointer.y);
});
This is a longshot, but I'd like to mimic the zoom behavior in the game Distant Worlds.