-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCursorManager.gd
28 lines (24 loc) · 951 Bytes
/
CursorManager.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class_name CursorManager extends Node
@export var speaker : AudioStreamPlayer2D
@export var cursor_point : CompressedTexture2D
@export var cursor_hover : CompressedTexture2D
@export var cursor_invalid : CompressedTexture2D
var cursor_visible = false
var controller_active = false
func _ready():
SetCursor(false, false)
func SetCursor(isVisible : bool, playSound : bool):
if (playSound): speaker.play()
if (isVisible):
if (!controller_active): Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
else: Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
cursor_visible = true
if (!isVisible):
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
cursor_visible = false
func SetCursorImage(alias : String):
match(alias):
"point": Input.set_custom_mouse_cursor(cursor_point, 0, Vector2(12, 0))
"hover": Input.set_custom_mouse_cursor(cursor_hover, 0, Vector2(9, 0))
"invalid": Input.set_custom_mouse_cursor(cursor_invalid, 0, Vector2(12, 0))
pass