40 lines
709 B
GDScript
40 lines
709 B
GDScript
extends Control
|
|
|
|
|
|
@onready var resume_button = $CenterContainer/HBoxContainer/ResumeButton
|
|
@onready var quit_button = $CenterContainer/HBoxContainer/QuitButton
|
|
|
|
func _input(event):
|
|
if Input.is_action_just_pressed("Pause"):
|
|
toggle()
|
|
|
|
func toggle():
|
|
if self.visible:
|
|
unpause()
|
|
else:
|
|
pause()
|
|
|
|
func unpause():
|
|
self.hide()
|
|
get_tree().paused = false
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
|
|
func pause():
|
|
self.show()
|
|
resume_button.grab_focus()
|
|
get_tree().paused = true
|
|
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
|
|
|
func quit():
|
|
get_tree().quit()
|
|
|
|
|
|
func _on_kill_pressed():
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
func _on_restart_pressed():
|
|
toggle()
|
|
get_tree().reload_current_scene()
|