- A ready to use cursor with animation support
- An easy way to change the shape of the cursor
This addon creates an AnimatedSprite2D and makes it follow your mouse. However, this method has a frame of delay, if the precision is not to your liking, you can change the native cursor in the project settings (check the docs)
You can mitigate this by disabling the v-sync or limiting the frames.
You should use this addon if you want to have an animated cursor since the "hardware" option does not allow animated images.
Also there´s no way for i can see to change the cursor shape in code apart from using a control node.
Go to asset tab in your project and search for Awesome Scene Manager and install from there.
You can also get the same files from GodotAssetStore
Or
Go to the release page and grab the latest version, decompress the files in your addons folder (create one if theres none).
After installation, it will add an autoload called Cursor, this is how you will manage the mouse.
Cursor.mouse_mode = Input.MOUSE_MODE_VISIBLE
Cursor.shape = Cursor.Shapes.CURSOR_POINTING_HAND
You would need to change the mouse_mode from Cursor instead of Input to prevent the native cursor overlapping the sprite.
As you can see the cursor scene is a simple Node2D with an CanvasLayer and inside theres a AnimatedSprite2D called Sprite as his only child.
The canvas layer is there because some popups appears above the sprite, thats why it has the highest layer possible.
The scene has two important properties, the same as Input; mouse_mode and shape
Type | Name |
---|---|
Input.MouseMode | mouse_mode |
Cursor.Shapes | shape |
It works the same as Input.mouse_mode except it filters the modes where the cursor should be shown and it displays the sprite instead, to prevent an overlap.
This handles a custom Enum called Shapes, this enum is basically Input.CursorShape, I recreated it here because these build in Enums cannot be iterated trough.
You can use like so:
Cursor.shape = Cursor.Shapes.CURSOR_BUSY
And it gives:
Taking the name of the shape, it will search for an animation with a similar name, though without the CURSOR_ and lowercase. Following the previous example;
With a shape of Cursor.Shapes.CURSOR_BUSY
it will search for an animation called busy
in the AnimatedSprite2D
Cursor.Shapes.CURSOR_ARROW
becomes simply arrow
Cursor.Shapes.CURSOR_POINTING_HAND
becomes pointing_hand
and so on and so forth
You could also use the function get_shape_name
that returns a StringName of the current name of shape to search for the animation.