Mouse cursor
In games, the mouse cursor is usually visible on the screen, but sometimes you may want to hide it, change its appearance, or use a custom image for it. LibGDX provides built-in support for all of these options.
In the Saxion Game App, you can use the provided GameApp methods to control the mouse cursor easily.
Hiding the Cursor
If you want to hide the system cursor (for example, when creating a custom in-game cursor), you can use:
The cursor will disappear from the screen, but you can still get the current mouse position (see input handling).
To show the cursor again, use:
Using System Cursors
LibGDX has a few built-in system cursors like Arrow, Hand, Crosshair, Busy, VerticalResize, etc. You can switch between them easily:
Available cursors: Arrow, Hand, Crosshair, VerticalResize, HorizontalResize, Busy, Text.
This changes the appearance of the cursor without hiding it.
Custom Cursors
You can also use your own images for the cursor. For example, you might want a sword or magic wand as the cursor:
- filePath: the path to your PNG image.
- hotspotX and hotspotY: the point within the image that is the "active" point (the tip of the cursor).