Jump to content

Volume controls for music and sound effects


Anderberg
 Share

Recommended Posts

Like all other games I have music and sound effects. However, right now I only have one volume control which changes the game.sound.volume, of course impacting all sounds.

 

I would like to divide this into one volume control for the music and one for the sound effects. Does anyone know if this is built into Phaser somewhere? Or should I keep track of what audio objects that are music and which ones are sound effects? Is it possible to have two sound managers, one for music and one for sfx and would that even be appropriate?

 

I'm happy for your input on the matter :)

Link to comment
Share on other sites

I recently tried to find something slimier to this for phaser and I came up with nothing. 
 

To get around this I just two global volumes vars. One for Music and one for SFX. 

 

Then created two helper functions to call the sounds with their correct volumes. 

function playSFX(sound){	if(game.global.volumeSFX > 0){		sound.play('',0,game.global.volumeSFX);	}}function playMusic(music){	if(game.global.volumeMusic > 0)		music.play('',1,game.global.volumeMusic,true);	}}

Works well for me but I am not sure if there is a better way to do it. 

Link to comment
Share on other sites

I've been pondering a solutions like yours, maybe that is the way to go for med too.
The music will probably always be a single audio file in my case, so that audio object could be saved individually in some variable. Then you iterate over all the sounds that isn't that one when changing sound effect volume.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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