Umaga
Umaga

Reputation: 31

LIBGDX Custom Cursor

I'm looking to change the cursor image to a custom image for the android game i'm creating using LIBGDX. Can anyone give me a hint on how to change the cursor from the default to a custom cursor?

Upvotes: 2

Views: 1511

Answers (2)

Jens Piegsa
Jens Piegsa

Reputation: 7485

The API has been slightly changed:

Pixmap pixmap = new Pixmap(Gdx.files.internal("cursor.png"));
int xHotspot = pixmap.getWidth() / 2;
int yHotspot = pixmap.getHeight() / 2;
Cursor cursor = Gdx.graphics.newCursor(pixmap, xHotspot, yHotspot);
Gdx.graphics.setCursor(cursor);
pixmap.dispose();

Upvotes: 2

Saeed Masoumi
Saeed Masoumi

Reputation: 8916

You need to use setCursorImage()in Gdx.input, for example:

Pixmap pm = new Pixmap(Gdx.files.internal("yourimage.png"));
int xHotSpot = pm.getWidth() / 2;
int yHotSpot = pm.getHeight() / 2;

Gdx.input.setCursorImage(pm, xHotSpot, yHotSpot);
pm.dispose();

Upvotes: 2

Related Questions