1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-24 17:14:23 +00:00
hella-farm/behaviours/draggable.gd
Stefano Pigozzi 3d17dcd3f0
Make Sheeps Draggable with a CursorMagnet
Throwing and drag isn't implemented yet. Any ideas for how to do it with this framework?
Might be a good idea to do it on a branch first...
2024-04-14 07:46:06 +02:00

34 lines
524 B
GDScript

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)