Change volume in options menu

I made global variables, the slider always returns to halfway when I leave the scene and come back, the sound doesn’t change anyway



please explain in simple words or give an example, thanks !

You need to set the slider value at the beginning of the scene to what it was set to previously:

Also:

  1. use SquareBlueSlider.Value(), not MaxValue().
  2. set volume to the slider value or setting_vol.sound, not 100

ok it works :slight_smile: question: how to make the volume option save after the player leaves the game?? and how to set Setting_vol.sound so that when you first enter the game it is at 100% sound ? (now it is at minimum)

Use local storage. Write the value when it changes, load the value at the start of the scene

Change the initial value where you define the variable:

image

.

I have no idea how to do this [Solved] Show total time at end of level on "You Won" screen? - #40 by MrMen
How to Write and where to save this file? I entered these names from the link in action and found nothing

With this action:

image

replace:
LevelTimes with Setting_vol
LevelTimeSave with Setting_vol_save
MyGameName with the name of your game.

This will save the Setting_vol structure to local storage.


To load back the value, use these actions:

image

and replace:
LevelTimes with Setting_vol
LevelTimeSave with Setting_vol_save
MyGameName with the name of your game.

You could also change jsonLevelTimes with jsonSettingsVol, but that’s just a superficial change.


You don’t. GDevelop does this for you and saves it to local storage. To see the value, you can click ctrl + shift + i, and click on the application tab. There’ll be a section titled Storage, and it’s under that.

I can’t find the write and read action , and where exactly to add this action?

Load at the beginning of the scene.
Save whenever the slider has been volume value is changed.

ok thanks ! now I can’t find this (parse):

When you open the action menu, you can search for the action:

1 Like

Question: in global variables I have saved “Settings_vol” you have Setting_vol" should I change it in action? is there any difference?


Doesnt matter you can keep any name as long as the expression is correct.