rendered paste body public static void MouseCameraControl(Camera camera)
{
Cursor cursor = GuiManager.Cursor;
if (cursor.WindowOver == null && GuiManager.DominantWindowActive == false)
{
float pixelSize = 1/camera.PixelsPerUnitAt(0);
// middle-click drag moves the camera
if (InputManager.Mouse.ButtonDown(FlatRedBall.Input.Mouse.MouseButtons.MiddleButton))
{
camera.X += -InputManager.Mouse.XChange * pixelSize;
camera.Y += InputManager.Mouse.YChange * pixelSize;
}
// double-click the middle-mouse button to center on the mouse's position
if (InputManager.Mouse.ButtonDoubleClicked(FlatRedBall.Input.Mouse.MouseButtons.MiddleButton))
{
cursor.GetCursorPosition(camera, 0);
}
// mouse-wheel scrolling zooms in and out
if (InputManager.Mouse.ScrollWheel != 0 && GuiManager.DominantWindowActive == false)
{
if (camera.Orthogonal == false)
camera.Z *= 1 + System.Math.Sign(InputManager.Mouse.ScrollWheel) * -.1f;
else
{
camera.OrthogonalHeight *= 1 + System.Math.Sign(InputManager.Mouse.ScrollWheel) * -.1f;
camera.OrthogonalWidth *= 1 + System.Math.Sign(InputManager.Mouse.ScrollWheel) * -.1f;
}
}
}
}