Jump to content

Sound & Music Volume


Ninjadoodle
 Share

Recommended Posts

Hi @enpu

I've been looking through the docs, and it looks like both sounds and music have a volume property.

I know how to adjust volume for a specific sound, but I'm trying to make SFX and MUSIC ON/OFF buttons.

Is there a way I can set the volume for all SFX / MUSIC?

PS. I know I can do game.audio.playSound('sound.m4a', [volume]) ... but I'm hoping to not have to do it for every sound + I don't think it will change the volume when the sound is already playing.

Thanks in advance!

 

Link to comment
Share on other sites

Hi @8bitdna

Thanks for that, but I’m still hoping there is a univeral volume for sfx and one for music.

Using stopAll(), will stop all the sounds currently playing, when clicking the SoundFX OFF button, for example.

However, any new sounds will still play as normal.

I know I can play all new sound effects with my own volume variable, just wondering if there is a simpler way.

For example set the whole music channel to 0 volume and set the who SFX channel to 0 volume.

Link to comment
Share on other sites

Actually, another look in the audio class and I see two attributes which look like they might be what yours after:

    /**
        Initial music volume (0-1).
        @attribute {Number} musicVolume
        @default 1
    **/
    musicVolume: 1,

    /**
        Initial sound volume (0-1).
        @attribute {Number} soundVolume
        @default 1
    **/
    soundVolume: 1,

Maybe setting those will do the trick?

Link to comment
Share on other sites

Not stupid at all, I only spotted how to do it looking through the engine source code and saw a line with it in.  I assumed the same as you in the first instance!  I'd like to be able to get a little more fluent with the engine and JS so I can understand things better.  Some parts of JS whilst powerful are a pain to me at least :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...