mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 15:44:23 +00:00
Add a Cursor
parameter to drag
and drop
This commit is contained in:
parent
e2bbbccfea
commit
9e25d08020
2 changed files with 8 additions and 8 deletions
|
@ -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)
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue