GMTK-2024/gmtk_2024/scripts/level_select.gd

25 lines
781 B
GDScript3
Raw Normal View History

2024-08-17 18:06:43 +02:00
extends Control
func _ready():
2024-08-20 00:41:10 +02:00
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
2024-08-17 18:06:43 +02:00
setup_level_box()
2024-08-17 20:26:32 +02:00
connect_level_selected_to_level_box()
2024-08-17 18:06:43 +02:00
func setup_level_box():
for box in $Background/ClipControl/GridContainer.get_children():
box.level_num = box.get_index() + 1
2024-08-19 14:36:40 +02:00
#box.locked = true
2024-08-17 20:26:32 +02:00
$Background/ClipControl/GridContainer.get_child(0).locked = false
2024-08-17 18:06:43 +02:00
2024-08-17 20:26:32 +02:00
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"
2024-08-20 13:57:52 +02:00
get_tree().change_scene_to_file(next_level)
2024-08-17 20:26:32 +02:00
2024-08-17 18:06:43 +02:00
func _on_quit_button_pressed():
get_tree().change_scene_to_file("res://menu/main_menu/MainMenu.tscn")