Files
imnotsick/main_hub.gd
T
2025-06-05 17:13:19 +02:00

80 lines
1.7 KiB
GDScript

extends Control
@export var TitleScreen: PackedScene
@export var Office: PackedScene
@export var Bedroom: PackedScene
@export var TextScreens: PackedScene
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#Adding Scenes
var title_screen = TitleScreen.instantiate()
var office = Office.instantiate()
var bedroom = Bedroom.instantiate()
var text_screens = TextScreens.instantiate()
add_child(title_screen)
add_child(office)
add_child(bedroom)
add_child(text_screens)
#Naming Scenes
title_screen.name = "TitleScreen"
office.name = "Office"
bedroom.name = "Bedroom"
text_screens.name = "TextScreens"
#Hiding Scenes
title_screen.hide()
office.hide()
bedroom.hide()
#Showing TitleScreen
title_screen.show()
#Connecting Signals
title_screen.connect("new_game_pressed", _on_new_game_pressed)
#get_tree().change_scene_to_file("res://corridor.tscn")
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
# Starts a new game
func _on_new_game_pressed():
var text_container = $TextScreens/MarginContainer/IntroBoxContainer/TextContainer
transition("big", [$TitleScreen], [$TextScreens, text_container.get_child(0)])
await $TextScreens.on_transition_finished
for i in 4:
transition("small", [text_container.get_child(i)], [text_container.get_child(i+1)])
await $TextScreens.on_transition_finished
# Takes care of fading transitions between scenes
func transition(size, scenes_to_hide, scenes_to_show):
TransitionScreen.transition(size)
await TransitionScreen.on_fading_finished
for scene in scenes_to_hide:
scene.hide()
for scene in scenes_to_show:
scene.show()