Hi,
I create on a VBoxContainer that is populated with buttons from an array. This is the main menu of my simple game
This is my menu_button.gd script ` extends Node var _playing_option
func _ready():
get_node("btn_menu").connect("pressed", self, "_on_pressed")
pass
func _on_pressed():
print("been pressed")
game.playing_card = _playing_option
stage_manager.change_stage(stage_manager.STAGE_GAME)
pass
func set_playing_option(option):
get_node("btn_menu").set_text(option)
_playing_option = option
pass
func set_button_position(x, y):
get_node("btn_menu").set_pos(Vector2(x, y))
pass
func get_playing_option():
return _playing_option
pass
`
And this is the main function that create the buttons and set on the VBoxContainer:
func _do_create_buttons():
var y = (Globals.get("display/height") / 2) - (game.get_possible_cards().size() * ydelta) + (ydelta * 5);
for possible in game.get_possible_cards():
var menu_button = load("res://scenes/menu_button.tscn")
var button = menu_button.instance()
button.set_playing_option(possible)
button.set_button_position(x, y)
y += ydelta
get_node("vbox_buttons").add_child(button)
pass
My problem is that when I had 5 options it was okay but now I have 12 options and there is a few missing because the screen height is too small for the options.
How can I add a scroll ?
Regards!