Enlarge mobile joystick controls
This commit is contained in:
parent
7892a162f3
commit
ec20778215
4 changed files with 46 additions and 19 deletions
|
|
@ -17,6 +17,8 @@ extends SceneTree
|
|||
# on a stick nobody is holding
|
||||
|
||||
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 stage: int = 0
|
||||
|
|
@ -31,6 +33,11 @@ func _initialize() -> void:
|
|||
|
||||
func _check(stick: Control, label: String) -> bool:
|
||||
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 -------------------------------------------
|
||||
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
|
||||
|
||||
|
||||
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:
|
||||
elapsed += delta
|
||||
if stage != 0:
|
||||
|
|
@ -84,10 +103,15 @@ func _process(delta: float) -> bool:
|
|||
if elapsed < 0.2:
|
||||
return false
|
||||
stage = 1
|
||||
if not _check(main.get_node("UI/Joystick"), "movement stick"):
|
||||
if not _check_pair(main, "space"):
|
||||
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
|
||||
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")
|
||||
quit(0)
|
||||
return true
|
||||
|
|
|
|||
Loading…
Reference in a new issue