-
Notifications
You must be signed in to change notification settings - Fork 1
Main Menu Custom Cursor
Tarushi edited this page Oct 5, 2024
·
5 revisions
LibGDX allows you to replace the default system cursor with a custom one, enhancing the game's UI and player experience. This guide explains how to set up a custom cursor using Pixmap
and Gdx.graphics.newCursor()
.
Use a PNG image for the custom cursor, preferably around 32x32 or 64x64 pixels.
Pixmap pixmap = new Pixmap(Gdx.files.internal("images/CustomCursor.png"));
customCursor = Gdx.graphics.newCursor(pixmap, pixmap.getWidth() / 4, pixmap.getHeight() / 4);
Gdx.graphics.setCursor(customCursor);
pixmap.dispose(); // Clean up resources
@Override
public void dispose() {
customCursor.dispose();
}
- Use small, appropriately sized images.
- Set the hotspot correctly for intuitive clicking.
- Dispose of resources to avoid memory leaks.