From 8802e3ab41af8d5f46db397cf5ac5cb4206d1529 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:29:12 +0300 Subject: [PATCH] Slightly improve camera zoom and pan touch gestures Not quite there yet --- src/UI/Canvas/CanvasCamera.gd | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/UI/Canvas/CanvasCamera.gd b/src/UI/Canvas/CanvasCamera.gd index a7cf25800..fc6870611 100644 --- a/src/UI/Canvas/CanvasCamera.gd +++ b/src/UI/Canvas/CanvasCamera.gd @@ -78,13 +78,14 @@ func _input(event: InputEvent) -> void: zoom_camera(-1) elif event is InputEventMagnifyGesture: # Zoom gesture on touchscreens - if event.factor >= 1: # Zoom in - zoom_camera(1) + #zoom_camera(event.factor) + if event.factor >= 1.0: # Zoom in + zoom_camera(event.factor * 0.3) else: # Zoom out - zoom_camera(-1) + zoom_camera((event.factor * 0.7) - 1.0) elif event is InputEventPanGesture: # Pan gesture on touchscreens - offset = offset + event.delta.rotated(camera_angle) * 7.0 / zoom + offset = offset + event.delta.rotated(camera_angle) * 2.0 / zoom elif event is InputEventMouseMotion: if drag: offset = offset - event.relative.rotated(camera_angle) / zoom @@ -95,7 +96,7 @@ func _input(event: InputEvent) -> void: offset = offset + (dir.rotated(camera_angle) / zoom) * CAMERA_SPEED_RATE -func zoom_camera(dir: int) -> void: +func zoom_camera(dir: float) -> void: var viewport_size := viewport_container.size if Global.smooth_zoom: var zoom_margin := zoom * dir / 5