fuzzyworld

godot-shooter / commit

Pause game on death.

a670e3028c6a6eee440c64d0997cce8461cd259c · Pavel Safronov · 2023-11-06 16:02:10 -0800 · parents 6accbd999e2c

Pause game on death.
 Player.gd   | 2 ++
 Player.tscn | 1 +
 2 files changed, 3 insertions(+)

diff --git a/Player.gd b/Player.gd
index 4c3e7ed..2806aaa 100644
--- a/Player.gd
+++ b/Player.gd
@@ -42,6 +42,7 @@ func kill():
 	$CanvasLayer/CenterContainer/DeathScreen.show()
 	Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
 	z_index = -1
+	get_tree().paused = true
 
 func heal(amount: int = 1):
 	if dead:
@@ -94,4 +95,5 @@ func allow_fire():
 	can_fire = true
 
 func _on_Button_pressed() -> void:
+	get_tree().paused = false
 	restart()
diff --git a/Player.tscn b/Player.tscn
index 883bf7a..c06924c 100644
--- a/Player.tscn
+++ b/Player.tscn
@@ -48,6 +48,7 @@ margin_bottom = 84.0
 mouse_filter = 2
 
 [node name="DeathScreen" type="Control" parent="CanvasLayer/CenterContainer"]
+pause_mode = 2
 visible = false
 mouse_filter = 2
 size_flags_horizontal = 5