hexland/Scripts/GameCamera.gd

22 lines
431 B
GDScript3
Raw Normal View History

2022-08-23 14:12:59 -05:00
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)