mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-28 18:34:18 +00:00
26 lines
671 B
GDScript3
26 lines
671 B
GDScript3
|
extends Area2D
|
||
|
class_name Ghost
|
||
|
|
||
|
var is_dragging: bool
|
||
|
var previous_position: Vector2
|
||
|
|
||
|
func _input(event: InputEvent):
|
||
|
if event is InputEventMouseButton:
|
||
|
is_dragging = event.pressed
|
||
|
previous_position = event.position
|
||
|
elif event is InputEventScreenTouch:
|
||
|
is_dragging = event.pressed
|
||
|
previous_position = event.position
|
||
|
|
||
|
if is_dragging:
|
||
|
if event is InputEventMouseMotion:
|
||
|
var delta = event.position - previous_position
|
||
|
print(delta)
|
||
|
position += delta
|
||
|
previous_position = event.position
|
||
|
elif event is InputEventScreenDrag:
|
||
|
var delta = event.position - previous_position
|
||
|
print(delta)
|
||
|
position += delta
|
||
|
previous_position = event.position
|