
[ad_1]
I’m having a problem making an attempt to grasp the ButtonGroup logic, completely new to GDScript, haven’t got a clue of what I’m doing. Obviously is improper.
I created a scene that I saved in a folder known as “Interface”, right here is the way it seems to be. Sorry, I do know it is most likely messy:
The scene is named “MenuButtons” and it seems to be as comply with:
The GDScript connected to the scene seems to be as comply with:
extends Control
export(ButtonGroup) var group
func _ready():
print(group.get_buttons())
for i in group.get_buttons():
i.join("pressed", self, "button_pressed")
func button_pressed():
var pressed_button = str(group.get_pressed_button())
var split_text = pressed_button.break up(':')
var button_method = str(split_text[0])
print(button_method)
if button_method == "NewGameButton": print('Restarting the sport')
if button_method == "OptionsButton": print('Opening the Options display screen')
if button_method == "ExitButton": print('Quiting the sport')
When I execute the scene with F6 all the pieces works as anticipated:
Still not what I’m anticipating, however it prints one thing. But right here is the state of affairs, I instantiated the MenuButtons scene as a node in one other scene known as GameOverlay, which is the check recreation UI.
This scene as effectively is instantiated contained in the Level Scene.
When the Level is run and the Game Over display screen reveals, neither group.get_buttons() technique returns an inventory and naturally the buttons don’t provoke the occasions. It appears to me that the script from MenuButtons doesn’t acknowledge the button group in any respect.
I used to be following two tutorials making an attempt to match their perception about utilizing buttons in Godot. Yeah, I don’t know what I’m doing as you possibly can inform. Any assist could be actually appreciated.
These are the tutorials I’m following:
[ad_2]