From 688790b5dc0ea8f51a99e42a00c7510b9bd87aa6 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 4 Dec 2024 14:23:42 +0100 Subject: next commit --- cursor.gd | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 cursor.gd (limited to 'cursor.gd') 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 -- cgit v1.2.3