Stage::setCursor()
Sets the cursor. It is recommended that the size is 16x16 or 32x32 pixels. The active spot of the cursor defaults to the top left corner (x = 0, y = 0). You can set the active spot by using the x and y argument. The values for the parameters x and y must be less than the dimensions of the image.
Examples
import org.openpatch.scratch.*;
public class StageSetCursor {
public StageSetCursor() {
Stage myStage = new Stage(600, 240);
while (myStage.getTimer().forMillis(5000)) {
if (myStage.getMouseX() < 0) {
myStage.setCursor("assets/cursor_hand.png");
} else {
myStage.setCursor("assets/cursor_sword.png", 30, 30);
}
myStage.display("Mouse: " + myStage.getMouseX() + ", " + myStage.getMouseY());
myStage.wait(16);
}
myStage.exit();
}
public static void main(String[] args) {
new StageSetCursor();
}
}
Syntax
Java
.setCursor(path), .setCursor(path,x,y)
Scratch
Parameters
Name | Data Type | Description |
---|---|---|
path | String | The path to the image |
x | int | The x coordinate of the active spot of the cursor. |
y | int | The y coordinate of the active spot of the cursor. |
Return
void