How could I to add many buttons on VBoxContainer?

Godot Version

4.3

Question

I have been trying to create a game of DOMINO. To do this I created an Inherited Scene to works as stone of DOMINO using buttons, then created a Principal Scene to add the buttons into a VBoxContainer to the players click on buttons and play the game. The problem is that I can’t add the buttons in VBoxContainer because it always display just one button and does not show others. I’ve also tried to use GridContainer but it still doesn’t works
How could I fix this problem adding all buttons on VBoxContainer ?

##CONFS
@export_category("DOMINO STONES")
@export var _pedras = [
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn"),
	preload("res://DominoX/pedras/0_1.tscn"),
	preload("res://DominoX/pedras/0_0.tscn")
]
var _rng = RandomNumberGenerator.new()

@export_category("PANELS")
#@export var _panel_topo: GridContainer
#@export var _panel_bottom: GridContainer
@export var _panel_left: VBoxContainer
#@export var _panel_right: VBoxContainer

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	_rng.randomize()
	_spawn_random_object()
	
func _process(delta: float) -> void:
	pass
	
func _spawn_random_object():
	#seleciona as pedras aleatoriamente 	
	while(_controle.size() < _pedras.size()):
		var _random_index = _rng.randi() % _pedras.size()
		if(!self._controle.has(_random_index)):
			self._controle.append(_random_index)
	
	#pega pedras selecionados de 7 em 7		
	var _topo = _controle.slice(0,7)
	var _bottom = _controle.slice(7, 14)
	var _left = _controle.slice(14, 21)
	var _right = _controle.slice(21, 28)	
	
	#adiciona pedras ao VBoxContainerLeft
	_panel_left.add_child(_pedras[_left[0]].instantiate())
	_panel_left.add_child(_pedras[_left[1]].instantiate())
	_panel_left.add_child(_pedras[_left[2]].instantiate())
	_panel_left.add_child(_pedras[_left[3]].instantiate())
	_panel_left.add_child(_pedras[_left[4]].instantiate())
	_panel_left.add_child(_pedras[_left[5]].instantiate())
	_panel_left.add_child(_pedras[_left[6]].instantiate())

I already fixed it. I just changed the Inherited Scene to use only TextureButton as root instead of Node2D and it works so well.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.