oh-my-git/card.gd

22 lines
546 B
GDScript3
Raw Normal View History

2020-10-13 13:04:12 +02:00
extends Node2D
var dragged = false
var drag_offset
func _ready():
set_process_unhandled_input(true)
func _process(delta):
if dragged:
var mousepos = get_viewport().get_mouse_position()
position = mousepos - drag_offset
func _unhandled_input(event):
print("input event!")
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed:
dragged = true
drag_offset = get_viewport().get_mouse_position() - global_position
elif event.button_index == BUTTON_LEFT and !event.pressed:
dragged = false