22 lines
431 B
GDScript
22 lines
431 B
GDScript
extends Camera2D
|
|
|
|
const ZOOM_SPEED = 0.2
|
|
|
|
var pan = false
|
|
|
|
func _process(_delta):
|
|
if Input.is_action_just_released("ui_zoom_in"):
|
|
zoom -= Vector2.ONE * ZOOM_SPEED
|
|
elif Input.is_action_just_released("ui_zoom_out"):
|
|
zoom += Vector2.ONE * ZOOM_SPEED
|
|
|
|
if Input.is_action_pressed("ui_pan"):
|
|
pan = true
|
|
else:
|
|
pan = false
|
|
|
|
func _input(event):
|
|
if event is InputEventMouseMotion:
|
|
if pan:
|
|
translate(-event.relative * zoom)
|