2024-04-16 01:56:46 +02: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 02:23:01 +02:00
|
|
|
func _on_area_entered(body: Area2D) -> void:
|
2024-04-16 01:56:46 +02:00
|
|
|
if body is Cursor:
|
|
|
|
mouse_inside = true
|
|
|
|
cursor_entered.emit(body)
|
|
|
|
|
2024-04-20 02:23:01 +02:00
|
|
|
func _on_area_exited(body: Area2D) -> void:
|
2024-04-16 01:56:46 +02:00
|
|
|
if body is Cursor:
|
|
|
|
mouse_inside = true
|
|
|
|
cursor_exited.emit(body)
|
2024-04-17 05:26:13 +02:00
|
|
|
|
2024-04-19 01:55:25 +02:00
|
|
|
func log_cursor(cursor: Cursor) -> void:
|
|
|
|
Log.p(self, "Cursor: %s" % cursor)
|