1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-23 00:24:21 +00:00
hella-farm/behaviours/draggable.gd

35 lines
524 B
GDScript3
Raw Normal View History

extends Area2D
class_name Draggable
signal move(movement: Vector2)
signal dragged
signal dropped
@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)
func drag():
being_dragged = true
dragged.emit()
func drop():
being_dragged = false
dropped.emit()
func _ready():
being_dragged = false
func _on_move(movement: Vector2):
move.emit(movement)