From 3912de50b9b9fa7de2e83942713d5a80f6080888 Mon Sep 17 00:00:00 2001 From: Melon Bread Date: Mon, 13 May 2024 20:01:29 -0400 Subject: [PATCH] Created title screen and set it as starting scene --- project.godot | 2 +- scenes/title_screen.tscn | 86 ++++++++++++++++++++++++++++++++++++++++ scripts/title_screen.gd | 10 +++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 scenes/title_screen.tscn create mode 100644 scripts/title_screen.gd diff --git a/project.godot b/project.godot index d8787b8..956d53d 100644 --- a/project.godot +++ b/project.godot @@ -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" diff --git a/scenes/title_screen.tscn b/scenes/title_screen.tscn new file mode 100644 index 0000000..5818fc4 --- /dev/null +++ b/scenes/title_screen.tscn @@ -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"] diff --git a/scripts/title_screen.gd b/scripts/title_screen.gd new file mode 100644 index 0000000..69a5bc4 --- /dev/null +++ b/scripts/title_screen.gd @@ -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()