From 877b5fc14fc5d766e3e74798673d7213c8e0262b Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 19 Jul 2025 21:24:38 +0400 Subject: [PATCH] Switch scenes on button press --- scenes/main.tscn | 4 +++- scripts/Main.gd | 16 ++++++++++++++++ scripts/Main.gd.uid | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 scripts/Main.gd create mode 100644 scripts/Main.gd.uid diff --git a/scenes/main.tscn b/scenes/main.tscn index ea5c53f..d170649 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=2 format=3 uid="uid://ci2gk11211n0d"] +[gd_scene load_steps=3 format=3 uid="uid://ci2gk11211n0d"] +[ext_resource type="Script" uid="uid://cwlop1ettlqhg" path="res://scripts/Main.gd" id="1_0wfyh"] [ext_resource type="PackedScene" uid="uid://gbe1jarrwqsi" path="res://ui/PressAnyKeyScreen.tscn" id="1_o5qli"] [node name="main" type="Control"] @@ -9,6 +10,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_0wfyh") [node name="PressAnyKeyScreen" parent="." instance=ExtResource("1_o5qli")] layout_mode = 1 diff --git a/scripts/Main.gd b/scripts/Main.gd new file mode 100644 index 0000000..982e733 --- /dev/null +++ b/scripts/Main.gd @@ -0,0 +1,16 @@ +extends Control + +@onready var press_any_key_screen = $PressAnyKeyScreen + +func _ready(): + print("Main scene ready") + # Connect the press any key signal + press_any_key_screen.any_key_pressed.connect(_on_any_key_pressed) + +func _on_any_key_pressed(): + print("Transitioning to main menu") + # Remove the press any key screen + press_any_key_screen.queue_free() + # Load and add the main menu + var main_menu = preload("res://ui/MainMenu.tscn").instantiate() + add_child(main_menu) diff --git a/scripts/Main.gd.uid b/scripts/Main.gd.uid new file mode 100644 index 0000000..ee3b621 --- /dev/null +++ b/scripts/Main.gd.uid @@ -0,0 +1 @@ +uid://cwlop1ettlqhg