-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add set cursor method and simplify coordinate rendering
- Loading branch information
1 parent
6b79038
commit dbe4c74
Showing
12 changed files
with
155 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"template": "method", | ||
"related": [], | ||
"scratchblock": "set cursor (file path)", | ||
"name": "setCursor()", | ||
"class": "Stage", | ||
"description": "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.", | ||
"syntax": [".setCursor(path), .setCursor(path,x,y)"], | ||
"returns": "void", | ||
"examples": [ | ||
{ | ||
"src": "StageSetCursor.java", | ||
"preview": "StageSetCursor.gif", | ||
"lines": "reg:[Rr]ecorder" | ||
} | ||
], | ||
"parameters": [ | ||
{ | ||
"name": "path", | ||
"description": "The path to the image", | ||
"type": "String" | ||
}, | ||
{ | ||
"name": "x", | ||
"type": "int", | ||
"description": "The x coordinate of the active spot of the cursor." | ||
}, | ||
{ | ||
"name": "y", | ||
"type": "int", | ||
"description": "The y coordinate of the active spot of the cursor." | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import org.openpatch.scratch.*; | ||
import org.openpatch.scratch.extensions.recorder.*; | ||
|
||
public class StageSetCursor { | ||
|
||
public StageSetCursor() { | ||
Stage myStage = new Stage(600, 240); | ||
GifRecorder recorder = | ||
new GifRecorder("examples/reference/" + this.getClass().getName() + ".gif"); | ||
recorder.start(); | ||
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); | ||
} | ||
recorder.stop(); | ||
myStage.exit(); | ||
} | ||
|
||
public static void main(String[] args) { | ||
new StageSetCursor(); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.