extends Control @onready var check_button_shape_1 = $VBoxContainer/BoxContainer/CircleButton @onready var check_button_shape_2 = $VBoxContainer/BoxContainer/TriangleButton @onready var check_button_shape_3 = $VBoxContainer/BoxContainer/SquareButton @onready var check_button_shape_4 = $VBoxContainer/BoxContainer/StarButton @onready var check_button_shape_5 = $VBoxContainer/BoxContainer/HouseButton @onready var check_button_shape_6 = $VBoxContainer/BoxContainer/UmbrellaButton @onready var container = $VBoxContainer/BoxContainer2 func _ready(): RenderingServer.set_default_clear_color(Color.SKY_BLUE) check_button_shape_1.connect("toggled", Callable(self, "_on_check_button_toggled").bind(check_button_shape_1)) check_button_shape_2.connect("toggled", Callable(self, "_on_check_button_toggled").bind(check_button_shape_2)) check_button_shape_3.connect("toggled", Callable(self, "_on_check_button_toggled").bind(check_button_shape_3)) check_button_shape_4.connect("toggled", Callable(self, "_on_check_button_toggled").bind(check_button_shape_4)) check_button_shape_5.connect("toggled", Callable(self, "_on_check_button_toggled").bind(check_button_shape_5)) check_button_shape_6.connect("toggled", Callable(self, "_on_check_button_toggled").bind(check_button_shape_6)) func _on_check_button_toggled(pressed: bool, button: CheckButton) -> void: var TextBoxScene = preload("res://TextBox.tscn") if pressed: var box = TextBoxScene.instantiate() # Instanciar la escena con el LineEdit box.get_node("LineEdit").text = button.name # Asignar el nombre del botón al LineEdit container.add_child(box) # Añadir el TextBox al contenedor else: for box in container.get_children(): if box.get_node("LineEdit").text == button.name: container.remove_child(box) # Eliminar el TextBox del contenedor box.queue_free() # Liberar el espacio ocupado por el TextBox break # Salir del ciclo una vez que hemos encontrado y eliminado el TextBox func get_current_order(): var order = [] for child in container.get_children(): order.append(child.get_node("LineEdit").text) return order func _on_play_button_pressed(): var bg_color = $VBoxContainer/bg_color_picker.color var line_color = $VBoxContainer/line_color_picker.color var radius = $VBoxContainer/radius_slider.value var width = $VBoxContainer/width_slider.value var game_scene = preload("res://GameScene.tscn").instantiate() var forma_dibujado = game_scene.get_node("Shape") var orden = get_current_order() print(orden.get(0)) # Pasamos los valores al nodo correcto forma_dibujado.circle_color = line_color forma_dibujado.radius = radius forma_dibujado.width = width forma_dibujado.shapes = orden game_scene.bg_color = bg_color ScreenManager.change_scene(game_scene, self)