Best way to deal with Sound On/Off toggle?

0 favourites
  • 9 posts
From the Asset Store
Best car suspension with spring effect and very cool terrain generation.
  • Hi there!

    It is the first time I'm messing around with sound, and I'm having a hard time trying to decide how to proceed with the ON/OFF sound toggle in the options menu.

    You guys have any ideas? What's the best way to proceed with this?

    (my main concerns are ease of use for the developer X game performance)

    1- Using a sub-event to test a global variable (isSoundOn) whenever I have to play a sound in the game. The problem with this one is having to add a sub event everytime I want to play a sound.

    2- Use a global variable to keep the sound volume (volumeLevel) that I can set to zero when the player clicks on the sound toggle. This is way more easy. My question here is: Will the sound be played even if there's no volume? Is it intensive enough for me to worry about it?

    I know it's not a big deal but I'm trying to understand how audio works in HTML5 <img src="smileys/smiley17.gif" border="0" align="middle" />

    Thanks in advance!

  • What I'd do is get the Function plugin and use function calls to play the sounds. So you have the function events in a separate group that you can disable when the toggle is set to off. That way the code that plays the sounds isn't executed and the sound doesn't play.

    This has the added benefit that you aren't messing with the volume to disable sounds. So if a player sets sound volume to say 70%, if he toggles it off and on the volume will still be 70%. Also when you lower the volume the sounds still play (obviously). I've found sound to be a bit wonky still on html5 (at least for me) and even with the volume set to 0 on repeated calls the volume will spike sometimes.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • inkBot

    If I could give you extra Rep I'd be doing it right now!

    Of course! I'm so stupid!

    I'm always talking about how the function plugin is great, and I totally forgot I could use it to make this. <img src="smileys/smiley5.gif" border="0" align="middle" />

    I'm gonna try that, and see how it goes.

    Thanks!

  • LOL I was searching in the forums about sound volume, and found my own topic! <img src="smileys/smiley17.gif" border="0" align="middle" />

    Anyway, method number 1 works GREAT!

  • Using the Audio Object you can Set Silent Mode to Silent | Not Silent | or Toggle Silent

    So if you just Toggle Silent on a Key Press of S it will alternately go silent and not silent

  • This is a bit of an older post, but it is still the first post that comes up in a search.

    I didn't want to make a new topic, that being said I have two sound related questions.

    Does 'Silent Mode' still load sounds into memory?

    I have a question about preloading a sound, can somebody explain what it does?

    The Manual and Description in C2 says it downloads an audio file online from a server.

    The 'Preload' description uses the term preload a lot.

    By Definition preloading means loading a file into memory before using it, and download means getting a file from another computer or server.

    You have to download a file from another computer before you can preload it into memory.

    An action exists called "Unload Audio".

    The description given say it "removes audio from memory", this implies 'Preload' loads audio to memory.

    So can someone clear up what Preloading a sound file does?

    Is it for downloading audio files from a server and/or preloading local sounds into memory so it plays better?

    I have been preloading local sounds before they are needed. I don't know if I need to be doing this or not.

  • on start of the layout

    if "sound" is not playing > then play "sound"

  • Preloading will download sounds into memory so that they play as soon as they're called - if they're not preloaded then when they're called there might be a delay before they play as it will take a little bit of time to download them.

    By default, sounds are automatically preloaded when the game is initially downloaded by the user but you can turn this feature off in the project settings - you may want to do this if you have lots of sounds and would like to reduce the initial loading time - you could then preload groups of sounds on a level-by-level basis, for example.

    Sounds take up space in memory, so if you have lots of sounds in memory that aren't going to be reused and your game is particularly memory hungry then you may want to clear up some space by unloading them. I assume that unloaded sounds would then need to be re-downloaded if they are called again.

    Hope that helps

  • I understand what the action of preloading something does and the use for it.

    The descriptions for 'Preload' in C2 threw me off a small bit.

    I just don't understand why the term 'download' and the phrase 'downloads from server' is being used to describe 'preload'.

    Preloading and downloading are two different things.

    By using the word 'download' it implies getting the file from a network or a different computer.

    I didn't think loading a file into memory is considered downloading. I am just confused on why the term download is being used.

    The sounds are downloaded when the game is downloaded.

    Sounds are loaded or preloaded when the game is running.

    It just seems like I am missing something.

    Can you download a sound file from a link as well as loading from local?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)