30 lines
768 B
GDScript
30 lines
768 B
GDScript
@icon("res://components/Cursor/mouse-pointer-2.svg")
|
|
extends Base
|
|
|
|
@onready var mouse_control = $"MouseControl"
|
|
|
|
|
|
func _process(delta):
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
|
mouse_control.position = mouse_control.get_global_mouse_position()
|
|
|
|
if Input.is_action_just_pressed("left_click"):
|
|
var overlapping_areas = mouse_control.get_overlapping_areas()
|
|
overlapping_areas.sort_custom(func(a, b):
|
|
return a.z_index > b.z_index
|
|
)
|
|
|
|
for area in overlapping_areas:
|
|
if area.has_method("_on_clicked"):
|
|
if not area._on_clicked():
|
|
break
|
|
|
|
|
|
func _on_mouse_control_area_entered(area):
|
|
if area.has_method("_on_hovered"):
|
|
area._on_hovered()
|
|
|
|
|
|
func _on_mouse_control_area_exited(area):
|
|
if area.has_method("_on_unhovered"):
|
|
area._on_unhovered()
|