Home Game Development gui – New to Godot having drawback understanding Button Group

gui – New to Godot having drawback understanding Button Group

0
gui – New to Godot having drawback understanding Button Group

[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:


enter image description here


The scene is named “MenuButtons” and it seems to be as comply with:


enter image description here


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:


enter image description here


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.


enter image description here


This scene as effectively is instantiated contained in the Level Scene.


enter image description here


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.


enter image description here


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:

  1. GODOT Menu System tutorial utilizing button themes 20 traces of code
  2. How to make use of a Button Group – Godot Engine

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here