22 lines
633 B
GDScript
22 lines
633 B
GDScript
## 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()
|