From a22381eff3bf2286ee27f4d15ddf4c431ea063be Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 12 Dec 2024 02:12:52 +0100 Subject: next commit --- cursor.gd | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'cursor.gd') diff --git a/cursor.gd b/cursor.gd index b8aac57..aa5eaad 100644 --- a/cursor.gd +++ b/cursor.gd @@ -1,26 +1,17 @@ extends Node2D -var sprite: Sprite - var current_action_idx := 0 var last_action_idx := 0 func _ready() -> void: - sprite = preload("res://sprite.tscn").instantiate() - sprite.load_file("res://data/extracted/data/sprite/cursors.spr") - add_child(sprite) - - sprite.action_data.frame_times[0] *= 2.0 - for idx in sprite.action_data.frame_times.size(): - sprite.action_data.frame_times[idx] *= 1.0 - Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + $Actions.play("000") func _process(_delta: float) -> void: - sprite.global_position = get_global_mouse_position() + global_position = get_global_mouse_position() if Input.get_current_cursor_shape() == Input.CURSOR_ARROW: current_action_idx = 0 @@ -29,22 +20,13 @@ func _process(_delta: float) -> void: else: current_action_idx = -1 - if current_action_idx == -1: - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - sprite.visible = false - elif current_action_idx != last_action_idx: - sprite.set_current_action(current_action_idx) - Input.mouse_mode = Input.MOUSE_MODE_HIDDEN - sprite.visible = true - - if current_action_idx == 0 and sprite.get_node("%SpriteLayers").get_child_count() == 1: - Input.set_custom_mouse_cursor(sprite.get_node("%SpriteLayers").get_child(0).texture.get_image()) - Input.mouse_mode = Input.MOUSE_MODE_VISIBLE - sprite.visible = false + if current_action_idx != last_action_idx: + if current_action_idx == -1: + Input.mouse_mode = Input.MOUSE_MODE_VISIBLE + $Actions.visible = false + else: + Input.mouse_mode = Input.MOUSE_MODE_HIDDEN + $Actions.visible = true + $Actions.play(str(current_action_idx).pad_zeros(3)) last_action_idx = current_action_idx - - -func _input(event: InputEvent) -> void: - if event is InputEventMouseButton: - pass -- cgit v1.2.3