Switch scenes on button press

This commit is contained in:
Your Name
2025-07-19 21:24:38 +04:00
parent e3e9d5591d
commit 877b5fc14f
3 changed files with 20 additions and 1 deletions

View File

@@ -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

16
scripts/Main.gd Normal file
View File

@@ -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)

1
scripts/Main.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://cwlop1ettlqhg