2024-04-14 05:21:24 +00:00
|
|
|
extends Area2D
|
2024-04-14 04:26:14 +00:00
|
|
|
class_name Draggable
|
|
|
|
|
|
|
|
|
2024-04-14 05:46:06 +00:00
|
|
|
signal move(movement: Vector2)
|
2024-04-14 04:26:14 +00:00
|
|
|
signal dragged
|
|
|
|
signal dropped
|
|
|
|
|
|
|
|
|
2024-04-14 05:46:06 +00:00
|
|
|
@onready var mover: Node2D = $"MatchMousePosition"
|
|
|
|
|
|
|
|
var being_dragged: bool:
|
|
|
|
get:
|
|
|
|
return being_dragged
|
|
|
|
set(value):
|
|
|
|
being_dragged = value
|
|
|
|
mover.set_process(being_dragged)
|
|
|
|
mover.set_physics_process(being_dragged)
|
2024-04-14 04:26:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
func drag():
|
|
|
|
being_dragged = true
|
|
|
|
dragged.emit()
|
|
|
|
|
|
|
|
func drop():
|
|
|
|
being_dragged = false
|
|
|
|
dropped.emit()
|
2024-04-14 05:46:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
being_dragged = false
|
|
|
|
|
|
|
|
func _on_move(movement: Vector2):
|
|
|
|
move.emit(movement)
|