0 votes

Hi all. I am trying to create an audio on and off option for my game. I managed to figure out how to code the options but no idea how to save/load them so that the setting is retained when the player closes the game and reopens it. I actually also need help on how to save/load show() and hide() of the on and off buttons (so that the on button is hidden after it is pressed and the off button is shown instead).

Appreciate you help. Thanks! :)

Godot version 3.3.4
in Engine by (29 points)

I have used that successfully for saving other things like highscore but the reason why I am asking here is because I don't quite get how to save show() hide() audio off calls. Sorry, I should have also explained that I am not a programmer and I am a newbie in this.

1 Answer

0 votes
Best answer

Create a global variable that keeps track of whether audio is on or off, and then when you load the game you check that variable and call hide or show as needed

by (1,342 points)
selected by

Thanks. I thought of another idea and it works as well. I hope it's not bad practice;

audio = true
#save audio boolean value

func _ready():
#load audio boolean value

if audioon == true:
#master_sound on
audioon_button.hide()       
audiooff_button.show()  
else:           
#master_sound off   
audioon_button.show()       
audiooff_button.hide()
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.