I don't have a specific example for an Isometric camera, but it sounds like you are asking about the basic camera system in general.
The camera I use in my games is somewhat simple and is illustrated in the figure below:
The Camera class contains the following member variables:
Converting from world coordinates to camera coordinates is only a matter of subtracting the position of the object from the position of the camera, and going from camera coordinates to world coordinates is only addition.
Getting the position of the mouse on the screen in a 2D game is almost identical to getting the position of an object, and all we have to do is get the on-screen mouse coordinates and add them to the position of the camera.
I do this using the following functions (and various overloads for Vector2, int, etc):
Note: The variable position refers to Camera.position, and worldRectangle is defined when the camera is created
/// Converts a rectangle in Pixel-based World coordinates to
/// camera view Screen coordinates
/// <param name="worldRectangle">Rectangle to convert</param>
/// <returns>The new Screen-based Rectangle</returns>
public Rectangle WorldToScreen(Rectangle worldRectangle)
return new Rectangle(
worldRectangle.Left - (int)(position.X),
worldRectangle.Top - (int)(position.Y),
/// Converts a rectangle in Screen coordinates to World coordinates
/// <param name="screenRectangle">Rectangle to convert</param>
/// <returns>The new World-based Rectangle</returns>
public Rectangle ScreenToWorld(Rectangle screenRectangle)
return new Rectangle(
screenRectangle.Left + (int)position.X,
screenRectangle.Top + (int)position.Y,
So in order for you to convert mouse coordinates to world coordinates, all you have to do is have a simple function like the one below, and then pass it to your script:
public Vector2 ScreenToWorld(int x, int y)
return new Vector2(position.X + x, position.Y + y);
This can be confirmed mathematically using the image above and Photoshop (assume pixel units). Suppose that the top left of the world is (0, 0) and the Camera's Viewport is defined by the Rectangle(623, 15, 683, 436).
If we hover the mouse over the top-left corner of the player, we get the coordinates (364, 276). In order to find the world location of the point, we add the camera location:
x-coordinate = 364 + 623
y-coordinate = 276 + 15
Which gives us the final coordinates: (987, 291)