From 802ccfa0135a4fc2ebcd866fb5217209b5f6f56f Mon Sep 17 00:00:00 2001 From: Hamcha Date: Sat, 1 Jun 2019 00:58:19 +0200 Subject: [PATCH] Fix some viewport scaling shenanigans --- Scenes/BoardUI.tscn | 1 + Scenes/Scripts/Board.gd | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Scenes/BoardUI.tscn b/Scenes/BoardUI.tscn index 2df4728..61cd049 100644 --- a/Scenes/BoardUI.tscn +++ b/Scenes/BoardUI.tscn @@ -66,6 +66,7 @@ script = ExtResource( 1 ) [node name="Panel" type="Panel" parent="."] anchor_right = 1.0 margin_bottom = 40.0 +rect_pivot_offset = Vector2( -60, -230 ) mouse_filter = 2 size_flags_horizontal = 3 size_flags_vertical = 3 diff --git a/Scenes/Scripts/Board.gd b/Scenes/Scripts/Board.gd index 9a4bb86..3f87212 100644 --- a/Scenes/Scripts/Board.gd +++ b/Scenes/Scripts/Board.gd @@ -10,7 +10,7 @@ onready var oppHand := $Camera/OppHand onready var ui := $BoardUI onready var cards := $Cards -export var mouseHandThreshold = 0.85 +export var mouseHandThreshold = 0.90 var holdingCard: Card = null var focusedCard: Card = null @@ -61,6 +61,8 @@ func _input(event: InputEvent): mouseOrigin = get_viewport().get_mouse_position() lastCameraTransform = camera.transform +var baseViewport := Vector2(1280, 720) + func _process(delta: float): # If mouse is under a certain area then we're managing our hand var absMousePos := get_viewport().get_mouse_position() @@ -72,7 +74,7 @@ func _process(delta: float): # If holding a card, move it between board/hand if holdingCard != null: # Check if we're selecting our hand while holding a card - var relPos: Vector2 = absMousePos / get_viewport().size + var relPos := get_viewport().get_mouse_position() / baseViewport var xMargin = 1.0-HAND_SCREEN_PERC var selectingHand: bool = relPos.y > mouseHandThreshold and (relPos.x > xMargin/2 and relPos.x < (1.0-xMargin/2)) # Move card in/out hand