Created title screen and set it as starting scene

This commit is contained in:
Rain Clark 2024-05-13 20:01:29 -04:00
parent 35af1d3d29
commit 3912de50b9
3 changed files with 97 additions and 1 deletions

View File

@ -11,7 +11,7 @@ config_version=5
[application]
config/name="Comets.gd"
run/main_scene="res://scenes/game.tscn"
run/main_scene="res://scenes/title_screen.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
boot_splash/show_image=false
config/icon="res://icon.png"

86
scenes/title_screen.tscn Normal file
View File

@ -0,0 +1,86 @@
[gd_scene load_steps=5 format=3 uid="uid://boelgbxjmyage"]
[ext_resource type="Script" path="res://scripts/title_screen.gd" id="1_87wa4"]
[ext_resource type="FontFile" uid="uid://bkcxbtx1vcj8w" path="res://assets/fonts/Color Basic.otf" id="1_d1y85"]
[ext_resource type="PackedScene" uid="uid://cemhlom425afn" path="res://scenes/stars.tscn" id="2_jj7dc"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vvgfx"]
bg_color = Color(0, 0, 0, 1)
border_width_left = 4
border_width_top = 4
border_width_right = 4
border_width_bottom = 4
border_color = Color(1, 1, 1, 1)
[node name="TitleScreen" 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_87wa4")
[node name="Panel" type="Panel" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_vvgfx")
[node name="TitleLabel" type="Label" parent="Panel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -11.5
offset_right = 20.0
offset_bottom = 11.5
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource("1_d1y85")
theme_override_font_sizes/font_size = 64
text = "COMETS.gd"
[node name="StartButton" type="Button" parent="Panel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -220.0
offset_top = 92.0
offset_right = -89.0
offset_bottom = 120.0
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource("1_d1y85")
text = "start"
[node name="QuitButton" type="Button" parent="Panel"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 88.0
offset_top = 92.0
offset_right = 219.0
offset_bottom = 120.0
grow_horizontal = 2
grow_vertical = 2
theme_override_fonts/font = ExtResource("1_d1y85")
text = "exit
"
[node name="Stars" parent="Panel" instance=ExtResource("2_jj7dc")]
[connection signal="pressed" from="Panel/StartButton" to="." method="_on_start_button_pressed"]
[connection signal="pressed" from="Panel/QuitButton" to="." method="_on_quit_button_pressed"]

10
scripts/title_screen.gd Normal file
View File

@ -0,0 +1,10 @@
extends Control
func _ready() -> void:
$Panel/StartButton.grab_focus()
func _on_start_button_pressed() -> void:
get_tree().change_scene_to_file("res://scenes/game.tscn")
func _on_quit_button_pressed() -> void:
get_tree().quit()