Skip to content

A customizable cursor for games games in the Godot Engine 4.2 and up

License

Notifications You must be signed in to change notification settings

DaviD4Chirino/awesome-custom-cursor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Awesome Custom Cursor

plugin icon

GitHub License GitHub Repo stars

Features

  • A ready to use cursor with animation support
  • An easy way to change the shape of the cursor

alt text

Use cases

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.

Installation

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).

Usage

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.

The Cursor Scene

Cursor Scene Demonstration

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

Properties

Type Name
Input.MouseMode mouse_mode
Cursor.Shapes shape

mouse_mode

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.

shape

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:

Example of the cursor turning busy

Sprites and Animations

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

An example of how the animations are structured

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.

About

A customizable cursor for games games in the Godot Engine 4.2 and up

Resources

License

Stars

Watchers

Forks

Packages

No packages published