2024-04-15 23:56:46 +00:00
|
|
|
@icon("res://behaviours/cursor_detector.svg")
|
|
|
|
extends Area2D
|
|
|
|
class_name CursorDetector
|
|
|
|
|
|
|
|
|
|
|
|
signal cursor_entered(cursor: Cursor)
|
|
|
|
signal cursor_exited(cursor: Cursor)
|
|
|
|
|
|
|
|
|
|
|
|
var mouse_inside = false
|
|
|
|
|
|
|
|
|
2024-04-20 00:23:01 +00:00
|
|
|
func _on_area_entered(body: Area2D) -> void:
|
2024-04-15 23:56:46 +00:00
|
|
|
if body is Cursor:
|
|
|
|
mouse_inside = true
|
|
|
|
cursor_entered.emit(body)
|
|
|
|
|
2024-04-20 00:23:01 +00:00
|
|
|
func _on_area_exited(body: Area2D) -> void:
|
2024-04-15 23:56:46 +00:00
|
|
|
if body is Cursor:
|
|
|
|
mouse_inside = true
|
|
|
|
cursor_exited.emit(body)
|
2024-04-17 03:26:13 +00:00
|
|
|
|
2024-04-18 23:55:25 +00:00
|
|
|
func log_cursor(cursor: Cursor) -> void:
|
|
|
|
Log.p(self, "Cursor: %s" % cursor)
|