The mouse position is a coordinate representing the position of the mouse on the Stage. It uses the Cartesian coordinate system, with bounds for the X coordinate at ±240 and bounds for the Y coordinate at ±180.

Related Blocks

Blocks which reference the mouse position include:

  • go to (mouse-pointer v) — Moves a sprite to mouse's position if the "mouse-pointer" option is selected in the dropdown
  • glide () secs to (mouse-pointer v) — Glides a sprite towards the mouse's position for a specified length if the "mouse-pointer" option is selected in the dropdown
  • point towards (mouse-pointer v) — Makes a sprite point towards the mouse's position if the "mouse-pointer" option is selected in the dropdown
  • mouse x — Reports the mouse's X position
  • mouse y — Reports the mouse's Y position

Example Uses

Some common uses for the Mouse Coordinates value are below:

  • Sliders

In a project, if something needs to be adjustable, then a slider can be used that can be controlled using the mouse.

The slider button (the sprite that will slide back and forth) should have these scripts:

when this sprite clicked
repeat until <not<mouse down?>>
    set [main value v] to (mouse x)
    go to x:(main value) y:(180)
end

The script can also be adjusted to make a vertical slider:

when this sprite clicked
repeat until <not<mouse down?>>
    set [main value v] to (mouse y)
    go to x:(240) y:(main value)
end

The constant X or Y position can be any value, and the main value is the value that will be controlled by the slider.

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.