From Test-Scratch-Wiki

Translate: - English - 中文 
This eng is about the block. For more information on the value this block reports, see Mouse X (value).
Mouse X
2.0 Mouse X.png
Category Sensing
Type Reporter
The Mouse X block is a Sensing block and a Reporter block. The block holds (reports) the mouse-pointer's current Mouse X.

Example Uses

As this block helps report where the mouse-pointer's current location, it is useful in sensing things with the mouse.

Some common uses for the Mouse X block:

  • Depending on where the mouse is, performing a different action
when [space v] key pressed
if <(mouse x) > [100]> then
repeat (10)
change [ghost v] effect by (10)
end
wait (1) secs
clear graphic effects
else
change y by (50)
wait (0.5) secs
change y by (-50)
end
  • Helping to make a virtual slider
forever
set x to (mouse x)
  • With the Mouse Y block, giving the mouse's location
forever
say (join (mouse x) (join [, ] (mouse y)))

Workaround

Main article: List of Block Workarounds

This block can be replicated with the following code:

Warning Note: This requires a sprite dedicated to finding the X position of the mouse
forever
 go to [mouse-pointer v]
 set [Mouse X v] to (x position)

See Also