I am making a 2D shooting game on Javafx 8 and I would like to be able to make the cursor invisible so that I can replace it with crosshairs.
Is there anyway to make the mouse cursor invisible when it is on the scene?
To change your cursor, you'd use the scene.setCursor(String)
method.
To change image
Using a reference to your current scene, pass in Cursor.cursor("url")
to setCursor
:
scene.setCursor(Cursor.cursor("url"));
To remove the cursor
Using a reference to your current scene, pass in Cursor.NONE
to setCursor
:
scene.setCursor(Cursor.NONE);
You also might be interested in the Cursor.CROSSHAIR
value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With