camera.mouseX

Category:Game Lab

The x coordinate of the mouse translated to the camera view.

Moving or zooming the camera will not change sprite positions nor the values of World.mouseX and World.mouseY. camera.mouseX values are not limited to the size of the display area. As the camera moves right the camera.mouseX values will increase, as the camera moves left the camera.mouseX values will decrease.

Examples

function draw() {
  background("white");
  camera.x=World.mouseX;
  text("worldMouseX"+World.mouseX,World.mouseX,200);
  text("camera.x"+ camera.x,World.mouseX,225);
  text("cameraMouseX"+camera.mouseX,World.mouseX,250);
}

Syntax

camera.mouseX

Returns

The x coordinate of the mouse translated to the camera view.

Found a bug in the documentation? Let us know at documentation@code.org