Scratch for Java

Sprite::getMouse()

Retrieves the current position of the mouse cursor.

Examples

import org.openpatch.scratch.*;
 
public class SpriteGetMouse {
  public SpriteGetMouse() {
    Stage myStage = new Stage(600, 240);
    Sprite mySprite = new Sprite("zeta", "assets/zeta_green_badge.png");
    mySprite.changeY(30);
    mySprite.changeX(-100);
    myStage.add(mySprite);
    while (myStage.getTimer().forMillis(3000)) {
      mySprite.say("X: " + mySprite.getMouseX() + " Y: " + mySprite.getMouseY());
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new SpriteGetMouse();
  }
}
 

View on GitHub

Syntax

Java

.getMouse()

Return

Vector2

getMouse()

Create Shareable URL

Select Sections