19 lines
622 B
GDScript3
19 lines
622 B
GDScript3
|
extends ScrollContainer
|
||
|
|
||
|
var dragging = false
|
||
|
var drag_start_position = Vector2()
|
||
|
var scroll_start_position = Vector2()
|
||
|
|
||
|
func _input(event):
|
||
|
if event is InputEventMouseButton or event is InputEventScreenTouch:
|
||
|
if event.pressed:
|
||
|
dragging = true
|
||
|
drag_start_position = event.position
|
||
|
scroll_start_position = Vector2(get_h_scroll(), get_v_scroll())
|
||
|
else:
|
||
|
dragging = false
|
||
|
elif dragging and (event is InputEventMouseMotion or event is InputEventScreenDrag):
|
||
|
var delta = event.position - drag_start_position
|
||
|
set_h_scroll(scroll_start_position.x - delta.x)
|
||
|
set_v_scroll(scroll_start_position.y - delta.y)
|