Scratch for Java

Stage::getMouseX()

Returns x coordinate of the mouse.

Examples

import org.openpatch.scratch.*;
 
public class StageGetMouse {
  public StageGetMouse() {
    Stage myStage = new Stage(600, 240);
 
    while (myStage.getTimer().forMillis(3000)) {
      var mouseX = myStage.getMouseX();
      var mouseY = myStage.getMouseY();
 
      myStage.display("X: " + mouseX + " Y: " + mouseY);
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new StageGetMouse();
  }
}
 

View on GitHub

Syntax

Java

.getMouseX()

Scratch

(mouse x)

Return

float

getMouseX()