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

Add a Cursor parameter to drag and drop

This commit is contained in:
Steffo 2024-04-20 04:11:14 +02:00
parent e2bbbccfea
commit 9e25d08020
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
2 changed files with 8 additions and 8 deletions

View file

@ -3,17 +3,17 @@ extends Area2D
class_name Draggable
signal dragged
signal dropped
signal dragged(cursor: Cursor)
signal dropped(cursor: Cursor)
var being_dragged: bool = false
func drag():
func drag(cursor: Cursor):
being_dragged = true
dragged.emit()
dragged.emit(cursor)
func drop():
func drop(cursor: Cursor):
being_dragged = false
dropped.emit()
dropped.emit(cursor)

View file

@ -36,14 +36,14 @@ func drag():
var target = find_closest_target()
if target and not dragging:
dragging = target
target.drag()
target.drag(self)
dragged.emit(target)
func drop():
if dragging:
var target = dragging
dragging = null
target.drop()
target.drop(self)
dropped.emit(target)
func log_dragging() -> void: