Update pause menu
This commit is contained in:
parent
43bd8cb8fc
commit
fc1f024fdd
|
|
@ -1,35 +1,61 @@
|
|||
extends CanvasLayer
|
||||
|
||||
func _ready() -> void:
|
||||
$".".visible = false
|
||||
$AnimationPlayer.play("RESET")
|
||||
@export var pause_sound : AudioStream
|
||||
@export var resume_sound : AudioStream
|
||||
@export var click_sound : AudioStream
|
||||
|
||||
func resume() -> void:
|
||||
$".".visible = false
|
||||
get_tree().paused = false
|
||||
$AnimationPlayer.play_backwards("blur")
|
||||
@onready var resume_button: Button = $PanelContainer/VBoxContainer/Resume
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
|
||||
var is_transitioning : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
process_mode = Node.PROCESS_MODE_ALWAYS
|
||||
visible = false
|
||||
animation_player.play("RESET")
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if is_transitioning: return
|
||||
if event.is_action_pressed("pause"):
|
||||
if get_tree().paused:
|
||||
resume()
|
||||
else:
|
||||
pause()
|
||||
|
||||
func pause() -> void:
|
||||
$".".visible = true
|
||||
if is_transitioning: return
|
||||
is_transitioning = true
|
||||
|
||||
visible = true
|
||||
get_tree().paused = true
|
||||
$AnimationPlayer.play("blur")
|
||||
$PanelContainer/VBoxContainer/Resume.grab_focus.call_deferred()
|
||||
|
||||
func testEsc() -> void:
|
||||
if Input.is_action_just_pressed("pause") and !get_tree().paused:
|
||||
pause()
|
||||
elif Input.is_action_just_pressed("pause") and get_tree().paused:
|
||||
resume()
|
||||
UiAudio.play(pause_sound)
|
||||
animation_player.play("blur")
|
||||
await animation_player.animation_finished
|
||||
|
||||
resume_button.grab_focus()
|
||||
is_transitioning = false
|
||||
|
||||
func resume() -> void:
|
||||
if is_transitioning: return
|
||||
is_transitioning = true
|
||||
|
||||
UiAudio.play(resume_sound)
|
||||
animation_player.play_backwards("blur")
|
||||
await animation_player.animation_finished
|
||||
|
||||
visible = false
|
||||
get_tree().paused = false
|
||||
is_transitioning = false
|
||||
|
||||
func _on_resume_pressed() -> void:
|
||||
resume()
|
||||
|
||||
func _on_restart_pressed() -> void:
|
||||
resume()
|
||||
UiAudio.play(click_sound)
|
||||
get_tree().paused = false
|
||||
visible = false
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
func _on_quit_pressed() -> void:
|
||||
UiAudio.play(click_sound)
|
||||
get_tree().quit()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
testEsc()
|
||||
|
|
|
|||
Loading…
Reference in a new issue