Add pause menu

soundtrack
Ensar Sarajčić 2021-11-13 23:06:38 +01:00
parent 2bdced47ea
commit 0499ef52cd
3 changed files with 92 additions and 1 deletions

View File

@ -0,0 +1,20 @@
extends PopupDialog
func _process(_delta: float) -> void:
if Input.is_action_just_pressed("ui_cancel"):
if get_tree().paused:
hide()
get_tree().paused = false
else:
show()
get_tree().paused = true
func _on_ContinueButton_pressed():
hide()
get_tree().paused = false
func _on_ExitButton_pressed():
get_tree().paused = false
get_tree().change_scene("res://scenes/menu/main_menu.tscn")
get_tree().root.get_child(get_tree().root.get_child_count() - 1).queue_free()

View File

@ -0,0 +1,68 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://assets/fonts/kenney-future-narrow.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://scenes/menu/pause_menu.gd" type="Script" id=2]
[sub_resource type="DynamicFont" id=1]
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=2]
font_data = ExtResource( 1 )
[node name="PauseMenu" type="PopupDialog"]
pause_mode = 2
anchor_left = 0.25
anchor_top = 0.25
anchor_right = 0.75
anchor_bottom = 0.75
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 20.0
margin_top = 20.0
margin_right = -20.0
margin_bottom = -20.0
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
margin_right = 472.0
margin_bottom = 260.0
dragger_visibility = 1
[node name="Title" type="Label" parent="MarginContainer/VSplitContainer"]
margin_right = 472.0
margin_bottom = 18.0
custom_fonts/font = SubResource( 1 )
text = "Game Paused"
align = 1
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer"]
margin_top = 30.0
margin_right = 472.0
margin_bottom = 260.0
alignment = 1
[node name="ContinueButton" type="Button" parent="MarginContainer/VSplitContainer/VBoxContainer"]
margin_top = 89.0
margin_right = 472.0
margin_bottom = 113.0
custom_fonts/font = SubResource( 2 )
text = "Continue"
[node name="ExitButton" type="Button" parent="MarginContainer/VSplitContainer/VBoxContainer"]
margin_top = 117.0
margin_right = 472.0
margin_bottom = 141.0
custom_fonts/font = SubResource( 2 )
text = "Exit to main menu"
[connection signal="pressed" from="MarginContainer/VSplitContainer/VBoxContainer/ContinueButton" to="." method="_on_ContinueButton_pressed"]
[connection signal="pressed" from="MarginContainer/VSplitContainer/VBoxContainer/ExitButton" to="." method="_on_ExitButton_pressed"]

View File

@ -1,6 +1,7 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=11 format=2]
[ext_resource path="res://scenes/test_level.gd" type="Script" id=1]
[ext_resource path="res://scenes/menu/pause_menu.tscn" type="PackedScene" id=2]
[ext_resource path="res://icon.png" type="Texture" id=3]
[sub_resource type="PlaneMesh" id=1]
@ -37,6 +38,8 @@ albedo_texture = SubResource( 6 )
[node name="Spatial" type="Spatial"]
script = ExtResource( 1 )
[node name="PauseMenu" parent="." instance=ExtResource( 2 )]
[node name="PlayerSpawnLocation" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -53.0538, 4.97082, -42.7552 )