connect level select menu
This commit is contained in:
parent
6831dd3a3f
commit
734eda1e1f
10 changed files with 142 additions and 8 deletions
BIN
gmtk_2024/scripts/File-Icon-Sheet.png
Normal file
BIN
gmtk_2024/scripts/File-Icon-Sheet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
|
@ -14,6 +14,7 @@ func level_locked() -> void:
|
|||
|
||||
func level_unlocked() -> void:
|
||||
level_state(false)
|
||||
$Label.text = str(level_num)
|
||||
|
||||
func level_state(value: bool) -> void:
|
||||
disabled = value
|
||||
|
|
|
@ -2,12 +2,22 @@ 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 = false
|
||||
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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue