From 5065d8b93e2e8df999e335647130f9b4f60fe5b8 Mon Sep 17 00:00:00 2001 From: IcECreAm777 Date: Sat, 8 Jul 2023 18:20:50 +0200 Subject: better pause menu --- Nodes/game.tscn | 40 +++++++++++++++++++++++++--------------- Scripts/game.gd | 4 ++-- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Nodes/game.tscn b/Nodes/game.tscn index 5187a55..e97ba1b 100644 --- a/Nodes/game.tscn +++ b/Nodes/game.tscn @@ -1,9 +1,12 @@ -[gd_scene load_steps=3 format=3 uid="uid://cu0s2nljmac8c"] +[gd_scene load_steps=4 format=3 uid="uid://cu0s2nljmac8c"] [ext_resource type="Script" path="res://Scripts/game.gd" id="1_1dait"] [sub_resource type="AudioStream" id="AudioStream_n3sou"] +[sub_resource type="LabelSettings" id="LabelSettings_ylef8"] +font_size = 64 + [node name="Game" type="Node2D"] script = ExtResource("1_1dait") @@ -29,7 +32,11 @@ anchor_bottom = 0.5 text = "Finished " -[node name="PausePopup" type="Control" parent="."] +[node name="LoadedLevel" type="Node2D" parent="."] + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="PausePopup" type="Control" parent="CanvasLayer"] process_mode = 2 visible = false layout_mode = 3 @@ -39,38 +46,41 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="Panel" type="Panel" parent="PausePopup"] +[node name="Panel" type="Panel" parent="CanvasLayer/PausePopup"] layout_mode = 0 anchor_right = 1.0 anchor_bottom = 1.0 -[node name="Label" type="Label" parent="PausePopup/Panel"] +[node name="Label" type="Label" parent="CanvasLayer/PausePopup/Panel"] layout_mode = 0 anchor_right = 1.0 anchor_bottom = 0.3 text = "Game is Paused" +label_settings = SubResource("LabelSettings_ylef8") +horizontal_alignment = 1 +vertical_alignment = 1 -[node name="VBoxContainer" type="VBoxContainer" parent="PausePopup/Panel"] -layout_mode = 0 +[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/PausePopup/Panel"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.3 anchor_top = 0.3 -anchor_right = 1.0 +anchor_right = 0.7 anchor_bottom = 1.0 alignment = 1 -[node name="ResumeButton" type="Button" parent="PausePopup/Panel/VBoxContainer"] +[node name="ResumeButton" type="Button" parent="CanvasLayer/PausePopup/Panel/VBoxContainer"] layout_mode = 2 text = "Resume" -[node name="MainMenuButton" type="Button" parent="PausePopup/Panel/VBoxContainer"] +[node name="MainMenuButton" type="Button" parent="CanvasLayer/PausePopup/Panel/VBoxContainer"] layout_mode = 2 text = "Main Menu" -[node name="QuitButton" type="Button" parent="PausePopup/Panel/VBoxContainer"] +[node name="QuitButton" type="Button" parent="CanvasLayer/PausePopup/Panel/VBoxContainer"] layout_mode = 2 text = "Quit" -[node name="LoadedLevel" type="Node2D" parent="."] - -[connection signal="pressed" from="PausePopup/Panel/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"] -[connection signal="pressed" from="PausePopup/Panel/VBoxContainer/MainMenuButton" to="." method="_on_MainMenuButton_pressed"] -[connection signal="pressed" from="PausePopup/Panel/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"] +[connection signal="pressed" from="CanvasLayer/PausePopup/Panel/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"] +[connection signal="pressed" from="CanvasLayer/PausePopup/Panel/VBoxContainer/MainMenuButton" to="." method="_on_MainMenuButton_pressed"] +[connection signal="pressed" from="CanvasLayer/PausePopup/Panel/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"] diff --git a/Scripts/game.gd b/Scripts/game.gd index 3c4326f..42918c5 100644 --- a/Scripts/game.gd +++ b/Scripts/game.gd @@ -24,7 +24,7 @@ func _ready(): func _process(delta): if Input.is_action_just_pressed("ui_cancel"): get_tree().paused = true - $PausePopup.show() + $CanvasLayer/PausePopup.show() Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) @@ -33,7 +33,7 @@ func _on_QuitButton_pressed(): func _on_ResumeButton_pressed(): - $PausePopup.hide() + $CanvasLayer/PausePopup.hide() get_tree().paused = false Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) -- cgit