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 class_name Draggable
signal dragged signal dragged(cursor: Cursor)
signal dropped signal dropped(cursor: Cursor)
var being_dragged: bool = false var being_dragged: bool = false
func drag(): func drag(cursor: Cursor):
being_dragged = true being_dragged = true
dragged.emit() dragged.emit(cursor)
func drop(): func drop(cursor: Cursor):
being_dragged = false being_dragged = false
dropped.emit() dropped.emit(cursor)

View file

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