World.mouseX

Category:Game Lab

The x coordinate of the mouse.

mouseX values are limited to the size of the display area. The default display area is 400 pixels x 400 pixels and the upper left corner is (0.0).

Examples

var sprite = createSprite(200, 200);
function draw() {
  background("white");
  sprite.x=World.mouseX;
  sprite.y=World.mouseY;
  drawSprites();
}

Syntax

World.mouseX

Returns

The x coordinate of the mouse.

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