mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-22 08:04: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
|
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)
|
||||||
|
|
|
@ -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:
|
||||||
|
|
Loading…
Reference in a new issue