Enlarge mobile joystick controls

This commit is contained in:
Loïc Wisniewski 2026-09-02 11:19:54 +02:00
commit ec20778215
4 changed files with 46 additions and 19 deletions

View file

@ -147,8 +147,8 @@ core_color = Color(0.02, 0.09, 0.15, 1)
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = 12 offset_left = 12
offset_right = 252 offset_right = 492
offset_top = -330 offset_top = -430
offset_bottom = -80 offset_bottom = -80
[node name="FireStick" type="Control" parent="UI"] [node name="FireStick" type="Control" parent="UI"]
@ -160,9 +160,9 @@ anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -252 offset_left = -492
offset_right = -12 offset_right = -12
offset_top = -330 offset_top = -430
offset_bottom = -80 offset_bottom = -80
[node name="SpeedFader" type="Control" parent="UI"] [node name="SpeedFader" type="Control" parent="UI"]

View file

@ -17,6 +17,8 @@ extends SceneTree
# on a stick nobody is holding # on a stick nobody is holding
const OFFSET := Vector2(-58.0, 41.0) const OFFSET := Vector2(-58.0, 41.0)
const MIN_TOUCH_AREA: float = 160000.0
const MIN_VISIBLE_RADIUS: float = 138.0
var main: Node var main: Node
var stage: int = 0 var stage: int = 0
@ -31,6 +33,11 @@ func _initialize() -> void:
func _check(stick: Control, label: String) -> bool: func _check(stick: Control, label: String) -> bool:
var home: Vector2 = stick.home_pos() var home: Vector2 = stick.home_pos()
if stick.size.x * stick.size.y < MIN_TOUCH_AREA:
return _fail("%s touch zone is only %s (%.0f area)" \
% [label, stick.size, stick.size.x * stick.size.y])
if stick.max_radius < MIN_VISIBLE_RADIUS:
return _fail("%s visible radius is only %.0f" % [label, stick.max_radius])
# --- A. idle means centred ------------------------------------------- # --- A. idle means centred -------------------------------------------
if stick.base_pos.distance_to(home) > 0.01 or stick.knob_pos.distance_to(home) > 0.01: if stick.base_pos.distance_to(home) > 0.01 or stick.knob_pos.distance_to(home) > 0.01:
@ -77,6 +84,18 @@ func _check(stick: Control, label: String) -> bool:
return true return true
func _check_pair(host: Node, label: String) -> bool:
var movement: Control = host.get_node("UI/Joystick")
var fire: Control = host.get_node("UI/FireStick")
if movement.get_global_rect().intersects(fire.get_global_rect()):
return _fail("%s joystick touch zones overlap" % label)
if not _check(movement, "%s movement stick" % label):
return false
if not _check(fire, "%s fire stick" % label):
return false
return true
func _process(delta: float) -> bool: func _process(delta: float) -> bool:
elapsed += delta elapsed += delta
if stage != 0: if stage != 0:
@ -84,10 +103,15 @@ func _process(delta: float) -> bool:
if elapsed < 0.2: if elapsed < 0.2:
return false return false
stage = 1 stage = 1
if not _check(main.get_node("UI/Joystick"), "movement stick"): if not _check_pair(main, "space"):
return true return true
if not _check(main.get_node("UI/FireStick"), "fire stick"): var surface: Node = load("res://surface/PlanetSurface.tscn").instantiate()
root.add_child(surface)
if not _check_pair(surface, "surface"):
return true return true
surface.queue_free()
print("both scenes provide non-overlapping 480x350 zones with %.0f-radius rings" \
% main.get_node("UI/Joystick").max_radius)
print("TEST_JOYSTICK_RECENTRES: PASS") print("TEST_JOYSTICK_RECENTRES: PASS")
quit(0) quit(0)
return true return true

View file

@ -23,7 +23,10 @@ signal released
# shorter side. Derived rather than a fixed number of pixels so that # shorter side. Derived rather than a fixed number of pixels so that
# enlarging the stick's rect enlarges the ring the player actually sees - # enlarging the stick's rect enlarges the ring the player actually sees -
# otherwise the touch area grows and the visible control stays small. # otherwise the touch area grows and the visible control stays small.
const RADIUS_RATIO: float = 0.28 # The scene zones are deliberately wider than they are tall. Forty percent
# makes the resting ring just over twice its former radius while leaving room
# for the floating base to move inside the touch rect.
const RADIUS_RATIO: float = 0.40
@export var max_radius: float = 90.0 @export var max_radius: float = 90.0
@export var deadzone: float = 0.12 @export var deadzone: float = 0.12

View file

@ -285,8 +285,8 @@ script = ExtResource("13")
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = 12 offset_left = 12
offset_right = 252 offset_right = 492
offset_top = -330 offset_top = -430
offset_bottom = -80 offset_bottom = -80
[node name="FireStick" type="Control" parent="UI"] [node name="FireStick" type="Control" parent="UI"]
@ -298,9 +298,9 @@ anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -252 offset_left = -492
offset_right = -12 offset_right = -12
offset_top = -330 offset_top = -430
offset_bottom = -80 offset_bottom = -80
[node name="SpeedFader" type="Control" parent="UI"] [node name="SpeedFader" type="Control" parent="UI"]
@ -340,8 +340,8 @@ anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -196 offset_left = -196
offset_right = -100 offset_right = -100
offset_top = -492 offset_top = -548
offset_bottom = -396 offset_bottom = -452
[node name="PivotCCWButton" type="Control" parent="UI"] [node name="PivotCCWButton" type="Control" parent="UI"]
mouse_filter = 2 mouse_filter = 2
@ -352,8 +352,8 @@ anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -468 offset_left = -620
offset_right = -364 offset_right = -516
offset_top = -130 offset_top = -130
offset_bottom = -26 offset_bottom = -26
@ -370,8 +370,8 @@ anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -324 offset_left = -324
offset_right = -228 offset_right = -228
offset_top = -424 offset_top = -548
offset_bottom = -328 offset_bottom = -452
[node name="GasBombStatus" type="Label" parent="UI"] [node name="GasBombStatus" type="Label" parent="UI"]
mouse_filter = 2 mouse_filter = 2
@ -414,8 +414,8 @@ anchor_left = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -356 offset_left = -508
offset_right = -252 offset_right = -404
offset_top = -130 offset_top = -130
offset_bottom = -26 offset_bottom = -26