From 66e7aefa223f4c3ef22754a1ebd0c3f162ca2785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 8 Nov 2023 12:29:40 +0100 Subject: Demo : drag map with right click --- demo/Main.gd | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/demo/Main.gd b/demo/Main.gd index 50c0ab6..15657e2 100644 --- a/demo/Main.gd +++ b/demo/Main.gd @@ -1,6 +1,5 @@ extends Node2D -var moved : int = 0 var drag_map : bool = false @onready var UI : Control = $CanvasLayer/HBOX/UI @@ -22,6 +21,7 @@ func _ready(): UI.get_node("OSInfo").text = "screen\n%s\ndpi %d" % [DisplayServer.screen_get_size(), DisplayServer.screen_get_dpi()] func on_viewport_resized() -> void: + print("Main->on_viewport_resized : %s" % $CanvasLayer/HBOX/ViewportContainer/Viewport.size) Camera.configure($CanvasLayer/HBOX/ViewportContainer/Viewport.size, Map.center(), Map.texture_size()) func on_rotate() -> void: @@ -43,22 +43,17 @@ func _unhandled_input(event : InputEvent) -> void: if drag_map: var dv : Vector2 = event.relative * Camera.zoom Camera.update_camera(-dv.x, -dv.y, 0) - moved += 1 else: Map.on_mouse_move() elif event is InputEventMouseButton: if event.button_index == 1: - if moved < 5: - drag_map = Map.on_click(event.pressed) - else: - drag_map = false - moved = 0 - elif event.button_index == 3: + Map.on_click(event.pressed) + elif event.button_index == 2: drag_map = event.pressed elif event.button_index == 4: on_zoom(true) elif event.button_index == 5: on_zoom(false) elif event is InputEventKey: - if event.scancode == KEY_ESCAPE: + if event.keycode == KEY_ESCAPE: get_tree().quit() -- cgit v1.1-2-g2b99