feat(home-button): add HomeButton component for hospital/garden navigation

This commit is contained in:
Steven Wroblewski
2026-04-17 21:18:52 +02:00
parent e7d0036c61
commit 1a5d7918ab
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
## HomeButton — tappable button that navigates between the hospital and the garden area.
class_name HomeButton extends Node2D
const BUTTON_HALF_SIZE: float = 32.0
@export var go_to_garden: bool = true
func _input(event: InputEvent) -> void:
if not event is InputEventScreenTouch:
return
if not (event as InputEventScreenTouch).pressed:
return
var touch_pos: Vector2 = (event as InputEventScreenTouch).position
var local: Vector2 = to_local(touch_pos)
if abs(local.x) > BUTTON_HALF_SIZE or abs(local.y) > BUTTON_HALF_SIZE:
return
if go_to_garden:
RoomNavigator.go_to_home()
else:
RoomNavigator.go_to_hospital()