|
@@ -1,9 +1,9 @@
|
|
|
.. _doc_custom_mouse_cursor:
|
|
|
|
|
|
Customizing mouse cursor
|
|
|
-=================================
|
|
|
+========================
|
|
|
|
|
|
-You might want to change the appearance of the mouse cursor in your game in order to suit the overall design of your game. There are two ways to customize the mouse cursor:
|
|
|
+You might want to change the appearance of the mouse cursor in your game in order to suit the overall design. There are two ways to customize the mouse cursor:
|
|
|
|
|
|
1. Using project settings
|
|
|
2. Using GDScript
|
|
@@ -11,7 +11,7 @@ You might want to change the appearance of the mouse cursor in your game in orde
|
|
|
Using project settings is a simpler but more limited way to customize the mouse cursor. The second way is more customizable but involves scripting.
|
|
|
|
|
|
Using project settings
|
|
|
-----------------------------
|
|
|
+----------------------
|
|
|
|
|
|
Open project settings, go to Display>Mouse Cursor. You will see Custom Image and Custom Image Hotspot.
|
|
|
|
|
@@ -20,10 +20,10 @@ Open project settings, go to Display>Mouse Cursor. You will see Custom Image and
|
|
|
Custom Image is the desired image that you would like to set as the mouse cursor.
|
|
|
Custom Hotspot is the point in the image that you would like to use as the cursor's detection point.
|
|
|
|
|
|
-.. note:: The custom image should be a png file and the size must be 32x32.
|
|
|
+.. note:: The custom image should be a PNG file and the size **must** be 32x32.
|
|
|
|
|
|
Using GDScript
|
|
|
-----------------------
|
|
|
+--------------
|
|
|
|
|
|
Create a Node and attach the following script.
|
|
|
|
|
@@ -32,27 +32,32 @@ Create a Node and attach the following script.
|
|
|
|
|
|
extends Node
|
|
|
|
|
|
- #Load the custom images for customizing the mouse cursor
|
|
|
+ # Load the custom images for the mouse cursor
|
|
|
var arrow = load("res://arrow.png")
|
|
|
var beam = load("res://beam.png")
|
|
|
|
|
|
func _ready():
|
|
|
- #This changes only the arrow case of the cursor
|
|
|
- #This is same as setting it in the project settings
|
|
|
+ # This changes only the arrow case of the cursor
|
|
|
+ # This is same as setting it in the project settings
|
|
|
Input.set_custom_mouse_cursor(arrow)
|
|
|
|
|
|
- #Change the appearance of the cursor in different cases
|
|
|
- #This changes the Ibeam case
|
|
|
+ # Change the appearance of the cursor in different cases
|
|
|
+ # This changes the Ibeam case
|
|
|
Input.set_custom_mouse_cursor(beam, Input.CURSOR_IBEAM)
|
|
|
|
|
|
.. code-tab:: csharp
|
|
|
|
|
|
.. note::
|
|
|
- Check :ref:`Input.set_custom_mouse_cursor() <class_Input_set_custom_mouse_cursor>`
|
|
|
+ Check :ref:`Input.set_custom_mouse_cursor() <class_Input_set_custom_mouse_cursor>`.
|
|
|
|
|
|
|
|
|
Demo project
|
|
|
-----------------------
|
|
|
+------------
|
|
|
|
|
|
-Find out more by studying this demo project.
|
|
|
+Find out more by studying this demo project:
|
|
|
https://github.com/guilhermefelipecgs/custom_hardware_cursor
|
|
|
+
|
|
|
+Cursor list
|
|
|
+-----------
|
|
|
+
|
|
|
+As documented in the :ref:`Input <class_Input>` class (see the **CursorShape** enum), there are multiple mouse cursors you can define. Which ones you want to use depends on your use case.
|