Add main menu as initial screen

This commit is contained in:
James Skemp 2023-11-11 12:38:39 -06:00
parent 9a28f39d21
commit 94a0c06f8d
5 changed files with 77 additions and 1 deletions

View File

@ -385,3 +385,8 @@ func death():
else:
result_label.text = "You Lose"
lose_sound.play()
func _on_menu_button_click_end():
get_tree().paused = false
get_tree().change_scene_to_file("res://TitleScreen/menu.tscn")

View File

@ -161,6 +161,7 @@ volume_db = -10.0
[node name="DeathPanel" type="Panel" parent="GUILayer/GUI"]
process_mode = 2
visible = false
layout_mode = 0
offset_left = 220.0
offset_top = -335.0
@ -230,5 +231,6 @@ columns = 10
[connection signal="body_exited" from="EnemyDetectionArea" to="." method="_on_enemy_detection_area_body_exited"]
[connection signal="area_entered" from="GrabArea" to="." method="_on_grab_area_area_entered"]
[connection signal="area_entered" from="CollectArea" to="." method="_on_collect_area_area_entered"]
[connection signal="click_end" from="GUILayer/GUI/DeathPanel/MenuButton" to="." method="_on_menu_button_click_end"]
[editable path="HurtBox"]

20
TitleScreen/menu.gd Normal file
View File

@ -0,0 +1,20 @@
extends Control
var level = "res://World/world.tscn"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func _on_play_button_click_end():
var _level = get_tree().change_scene_to_file(level)
func _on_exit_button_click_end():
get_tree().quit()

49
TitleScreen/menu.tscn Normal file
View File

@ -0,0 +1,49 @@
[gd_scene load_steps=4 format=3 uid="uid://dcw1wncfpv5x3"]
[ext_resource type="FontFile" uid="uid://c0h5wipmbmg66" path="res://Font/tenderness.otf" id="1_3r8l2"]
[ext_resource type="Script" path="res://TitleScreen/menu.gd" id="1_5ur4o"]
[ext_resource type="PackedScene" uid="uid://dl40punn4yr8d" path="res://Utility/basic_button.tscn" id="2_7uljj"]
[node name="Menu" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_5ur4o")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 0
offset_right = 655.0
offset_bottom = 375.0
color = Color(0.772549, 0, 0.00392157, 1)
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_right = 640.0
offset_bottom = 100.0
theme_override_fonts/font = ExtResource("1_3r8l2")
theme_override_font_sizes/font_size = 72
text = "SurvivorsClone"
horizontal_alignment = 1
vertical_alignment = 1
[node name="PlayButton" parent="." instance=ExtResource("2_7uljj")]
layout_mode = 0
offset_left = 280.0
offset_top = 250.0
offset_right = 360.0
offset_bottom = 280.0
text = "Play"
[node name="ExitButton" parent="." instance=ExtResource("2_7uljj")]
layout_mode = 0
offset_left = 280.0
offset_top = 290.0
offset_right = 360.0
offset_bottom = 320.0
text = "Exit"
[connection signal="click_end" from="PlayButton" to="." method="_on_play_button_click_end"]
[connection signal="click_end" from="ExitButton" to="." method="_on_exit_button_click_end"]

View File

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="SurvivorClone"
run/main_scene="res://World/world.tscn"
run/main_scene="res://TitleScreen/menu.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
config/icon="res://icon.svg"