Tough_Crowd/godot/scenes/ingame_scene.gd

26 lines
554 B
GDScript3
Raw Permalink Normal View History

2024-01-26 18:01:32 +00:00
extends Node2D
@onready var fade_overlay = %FadeOverlay
@onready var pause_overlay = %PauseOverlay
2024-01-26 18:01:32 +00:00
func _ready() -> void:
fade_overlay.visible = true
2024-01-26 18:01:32 +00:00
if SaveGame.has_save():
SaveGame.load_game(get_tree())
2024-01-26 18:01:32 +00:00
pause_overlay.game_exited.connect(_save_game)
2024-01-26 18:01:32 +00:00
func _input(event) -> void:
if event.is_action_pressed("pause") and not pause_overlay.visible:
get_viewport().set_input_as_handled()
get_tree().paused = true
pause_overlay.grab_button_focus()
pause_overlay.visible = true
2024-01-26 18:01:32 +00:00
func _save_game() -> void:
SaveGame.save_game(get_tree())