summaryrefslogtreecommitdiff
path: root/cursor.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-04 14:23:42 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-04 14:23:42 +0100
commit688790b5dc0ea8f51a99e42a00c7510b9bd87aa6 (patch)
tree71c04c9f401c67caf5c1ea3f56c7360ac1d14b86 /cursor.gd
parent2bf6b303fc062a800afb784877d989686287a2a7 (diff)
next commit
Diffstat (limited to 'cursor.gd')
-rw-r--r--cursor.gd37
1 files changed, 37 insertions, 0 deletions
diff --git a/cursor.gd b/cursor.gd
new file mode 100644
index 0000000..851441d
--- /dev/null
+++ b/cursor.gd
@@ -0,0 +1,37 @@
+extends Node
+
+
+@export var arrow_images: Array[Texture2D]
+@export_range(1.0, 10.0, 0.1) var arrow_speed := 7.0
+var arrow_idx := 0.0
+
+@export var click_images: Array[Texture2D]
+@export_range(1.0, 10.0, 0.1) var click_speed := 4.0
+var click_idx := 0.0
+
+class CurrentCursor:
+ var images: Array[Texture2D]
+ var speed: float
+ var idx: float
+
+
+func _process(delta: float) -> void:
+ if Input.get_current_cursor_shape() == Input.CURSOR_ARROW:
+ arrow_idx += (delta * arrow_speed)
+ if arrow_idx > arrow_images.size():
+ arrow_idx = 0
+
+ Input.set_custom_mouse_cursor(arrow_images[floor(arrow_idx)], Input.CURSOR_ARROW)
+ elif Input.get_current_cursor_shape() == Input.CURSOR_POINTING_HAND:
+ click_idx += (delta * click_speed)
+ if click_idx > click_images.size():
+ click_idx = 0
+
+ Input.set_custom_mouse_cursor(click_images[floor(click_idx)], Input.CURSOR_POINTING_HAND)
+ else:
+ Input.set_custom_mouse_cursor(null, Input.get_current_cursor_shape())
+
+
+func _input(event: InputEvent) -> void:
+ if event is InputEventMouseButton:
+ pass