Buttons that show more buttons.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RiqueDiaz

Hello! Is there a way that i can make a button, after being press, display two more buttons? Without scene change

:bust_in_silhouette: Reply From: Yuminous

In Button > Signals > BaseButton > pressed() creates a function (put it in the main scene script) that is run when the intial button is pressed:

func _on_Button_pressed():

You then have a couple of ways depending on what you want to happen.

First: if already you have the next two buttons already created in your scene (but hidden), then use .show() on both your other buttons, maybe like this:

func _on_Button_pressed():

Second option: you would like new buttons (created in the script):

var button_counter = 0

func _on_Button_pressed():
    for i in 2:
        button_counter += 1
        var new_button = Button.new()

After doing this you would then need to define every aspect of each button in the script, like its text, size, style, font, options, etx, for both buttons (this isn’t shown).

Hope it helps!

Thank you! It was way more simples than i was trying to make, haha. Thank you again

RiqueDiaz | 2021-07-15 03:00

:bust_in_silhouette: Reply From: Help me please

Yuminous has already provided you a great answer but you can also make these more appealing. Here’s a great tutorial by KidsCanCode

It’s somewhat complicated but still it will give you some lessons and you will learn many more great things.