Open craftworkgames opened 5 years ago
This issue came from a post on the community forum
These are new zoom functions for the MonoGame.Extended OrthographicCamera class
OrthographicCamera
public void ZoomIn(float deltaZoom, Vector2 zoomCenter) { float pastZoom = Zoom; ClampZoom(Zoom + deltaZoom); Position += (zoomCenter - Origin - Position) * ((Zoom - pastZoom) / Zoom); } public void ZoomOut(float deltaZoom, Vector2 zoomCenter) { float pastZoom = Zoom; ClampZoom(Zoom - deltaZoom); Position += (zoomCenter - Origin - Position) * ((Zoom - pastZoom) / Zoom); }
They can be called like this.
_worldPosition = _camera.ScreenToWorld(mouseState.Position.ToVector2()); // zoom targeting the mouse int previousMouseWheelValue = currentMouseWheelValue; currentMouseWheelValue = Mouse.GetState().ScrollWheelValue; if (currentMouseWheelValue > previousMouseWheelValue) { _camera.ZoomIn(1 / 12f, _worldPosition); } if (currentMouseWheelValue < previousMouseWheelValue) { _camera.ZoomOut(1 / 12f, _worldPosition); }
This is pushed back to v4 as I want to modify more of the surrounding code in its entirety before making changes.
This issue came from a post on the community forum
These are new zoom functions for the MonoGame.Extended
OrthographicCamera
classThey can be called like this.