mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-25 09:34:24 +00:00
Stefano Pigozzi
3d17dcd3f0
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...
34 lines
524 B
GDScript
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)
|