problems with audio control in godot 2.1.6

I’m using Godot 2.1.6 and I’m facing a problem with my game’s audio control.

Below is the script for my sound control node, a child node of my game’s main node.

the problem is that only the click sound control button (sound_box) has click sound. everything else is muted no matter how many times I click on it.

the music part works perfectly fine and the debug messages are also correct.

extends ReferenceFrame

onready var musica_de_fundo_menu = get_node("musica_de_fundo_menu")
onready var cliques_menu = get_node("cliques_menu")
onready var sem_cliques_menu = get_node("sem_cliques_menu")
onready var music_box = get_node("GridContainer/music_box")
onready var som_box = get_node("GridContainer/som_box")

# Assim que a aplicação é iniciada verifica se a música de fundo e os sons estavam
# ligados ou desligados, mantendo o estado apropriado
func _ready():

    configurar_musica()
    configurar_som()

# Faz uma ação ao pressionar o botão "music_box"
func _on_music_box_pressed():
    print("_on_music_box_pressed")
    # Se a música de fundo está tocando ela é parada
    if musica_de_fundo_menu.is_playing():
        musica_de_fundo_menu.stop()
        salva_estado_da_musica("pausada")
    # Se a música de fundo está pausada ela é acionada
    else:
        musica_de_fundo_menu.play()
        salva_estado_da_musica("tocando")

# Função para configurar a música de fundo com base no estado atual
func configurar_musica():
    var estado_musica = mantem_estado_da_musica()
    if str(estado_musica) == "tocando":
        music_box.set_pressed(true)
        musica_de_fundo_menu.play()
    else:
        music_box.set_pressed(false)
        musica_de_fundo_menu.stop()

# Salva o estado atual da música de fundo no arquivo "musica"
func salva_estado_da_musica(estado_musica):
    var estado = File.new()
    estado.open("res://musica", File.WRITE)
    estado.store_line(estado_musica)
    estado.close()
    print("Estado da música armazenado")

# Lê o arquivo "musica" e retorna o estado em que ela está/último estado em
# que foi posta pelos usuários.
# "tocando" se a música foi deixada ativada e "pausada" caso contrário.
func mantem_estado_da_musica():
    var salva = File.new()
    if not salva.file_exists("res://musica"):
        print("Arquivo inexistente")
        return 0
    else:
        salva.open("res://musica", File.READ)
        var linha_do_arquivo = salva.get_line().strip_edges()
        return linha_do_arquivo

# Faz uma ação ao pressionar o botão "som_box"
func _on_som_box_pressed():
    print("_on_som_box_pressed")
    # Se o som dos botões está ativado ele é parado
    print("Som is_playing: ", cliques_menu.is_playing())
    var estado_som = mantem_estado_do_som()
    if str(estado_som) == "ligado":
        print("Som de cliques parando")
        var desligado = "desligado"
        cliques_menu.stop()
        salva_estado_do_som(desligado)
        
        configurar_som()
    
    # Se o som dos cliques está desligado ele é ligado
    else:
        print("Som de cliques iniciando")
        var ligado = "ligado"
        cliques_menu.play()
        salva_estado_do_som(ligado)
        
        configurar_som()

# Função para configurar o som com base no estado atual
func configurar_som():
    print("configurar_som chamada")
    var estado_som = mantem_estado_do_som()
    if str(estado_som) == "ligado":
        som_box.set_pressed(true)
        conectar_botao_som(cliques_menu)
        print("cliques com som")
        
    else:
        som_box.set_pressed(false)
        conectar_botao_som(sem_cliques_menu)
        print("cliques silenciados")

# Função para coletar todos os nós de botão na árvore do cenário
func get_button_nodes(node):
    var button_nodes = []
    for child in node.get_children():
        if child extends Button:
            button_nodes.append(child)
        # Se o nó atual tiver filhos, recursivamente coleta os botões deles
        if child.get_child_count() > 0:
            button_nodes += get_button_nodes(child)
    
    return button_nodes

# Função para conectar todos os botões ao som especificado
func conectar_botao_som(som):
    # Obtém todos os nós no grupo "button"
    var button_nodes = get_tree().get_nodes_in_group("button")
    
    # Desconecta os sinais do som antes de conectar novamente
    som.disconnect("pressed", som, "play")
    som.disconnect("released", som, "stop")
    
    # Conecta cada botão ao som especificado
    for button_node in button_nodes:
        button_node.connect("pressed", som, "play")
        button_node.connect("released", som, "stop")

# Função auxiliar para conectar botões de forma recursiva
func conectar_botao_som_recursive(node, som):
    for child in node.get_children():
        if child extends Button:
            child.connect("pressed", som, "play")  # Conectar para reproduzir o som
            child.connect("released", som, "stop") # Conectar para parar o som
        conectar_botao_som_recursive(child, som)

# Salva o estado atual dos cliques no arquivo "som"
func salva_estado_do_som(estado_som):
    var estado = File.new()
    estado.open("res://som", File.WRITE)
    estado.store_line(estado_som)
    estado.close()
    print("Estado do som armazenado")

# Lê o arquivo "som" e retorna o estado em que ele está/último estado em
# que foi posto pelos usuários.
# "ligado" se o som foi deixado ativada e "desligado" caso contrário.
func mantem_estado_do_som():
    var salva = File.new()
    if not salva.file_exists("res://som"):
        print("Arquivo inexistente")
        return 0
    else:
        salva.open("res://som", File.READ)
        var linha_do_arquivo = salva.get_line().strip_edges()
        return linha_do_arquivo

I’ve already tested everything that gpt chat suggested to me and nothing. Even with this control on the main node, this only messed things up even more.

I need the so_box button to click and turn off the click sounds of all buttons in my game.

currently only the sound control button has a click sound, the others do not. all the music control, sound state recording and debug messages work.

New contributor

Dom_Quixote is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật