User Tools

Site Tools


en:tutorials:display:custom_mouse_cursor

Custom Mouse Cursors

The Cursor property allows you set the type of hardware mouse cursor image that is used when over the active window, or game. There are several standard ones built-in provided by the OSarrow, ibeam, crosshair, hand, hresize, vresize and default.

[Display]
Cursor = hand

Alternatively, a very nifty feature is to provide your own image as the cursor (png, jpg, bmp, tga or webp are all supported). Great for games where a fancy cursor is needed, ie:

[Display]
Cursor = amiga-cursor.png

By default, this will place the cursor's hotspot in the top left corner. You can move this hotspot by providing an optional vector, ie:

[Display]
cursor = amiga-cursor.png # (10, 10)

And like a normal cursor, it will hang outside the bounds of the window when you are the right or bottom extremes. Very nice.

You can change cursors using the Orx Console. Press the ~ key to open the console and type:

  Mouse.SetCursor crosshair

Finally, you can set a mouse cursor in code:

orxMouse_SetCursor("amiga-cursor.png", orxNULL);

This will set the cursor to the amiga arrow, and keep the default hotspot by using orxNULL. Change the hotspot position using a vector like:

orxVECTOR hotspot = orxVECTOR_0;
hotspot.fX = 10;
hotspot.fY = 10;
 
orxMouse_SetCursor("amiga-cursor.png", &hotspot);

Hiding the mouse cursor

If you don't want a cursor to display at all then you won't want to show it. You an use the ShowCursor in the Mouse section. See Mouse Config inputs for more details.

en/tutorials/display/custom_mouse_cursor.txt · Last modified: 2021/06/26 06:26 (3 years ago) by sausage