GMTK-2024/gmtk_2024/scripts/level_select.gd
2024-08-19 14:36:40 +02:00

23 lines
772 B
GDScript

extends Control
func _ready():
setup_level_box()
connect_level_selected_to_level_box()
func setup_level_box():
for box in $Background/ClipControl/GridContainer.get_children():
box.level_num = box.get_index() + 1
#box.locked = true
$Background/ClipControl/GridContainer.get_child(0).locked = false
func connect_level_selected_to_level_box():
for box in $Background/ClipControl/GridContainer.get_children():
box.connect("level_selected", change_to_scene)
func change_to_scene(level_num: int):
var next_level: String = "res://levels/level_" + str(level_num) + ".tscn"
if FileAccess.file_exists(next_level): get_tree().change_scene_to_file(next_level)
func _on_quit_button_pressed():
get_tree().change_scene_to_file("res://menu/main_menu/MainMenu.tscn")