Zampano Posted August 26, 2017 Share Posted August 26, 2017 Hey there! I'm a little confused about the soundManager and how to properly handle the playback of sounds. What I want to do is have a master volume for music and a master volume for sfx. When fading music in and out it always goes to a volume of 1 so it does not seem to be a good idea to handle the sound volumes individually for each sound or music track. Would I set up 2 different sound managers and add all sounds in there and then control the Soundmanagers volume? I can't seem to find proper examples or tutorials on that.. Any pointers would be greatly appreciated! Thanks Zampano Link to comment Share on other sites More sharing options...
samme Posted August 26, 2017 Share Posted August 26, 2017 I don't know if it will actually work but you would do Phaser.GameObjectFactory.prototype.music = function (key, volume, loop, connect) { return this.game.music.add(key, volume, loop, connect); }; Phaser.GameObjectFactory.prototype.musicSprite = function (key) { return this.game.music.addSprite(key); }; var gameState = { // abbreviated init: function () { this.game.music = new Phaser.SoundManager(this.game); this.game.music.boot(); }, preload: function () { this.load.audio('music1', 'path'); // as usual }, create: function () { this.add.music('music1'); this.add.musicSprite('musicSprite1'); // E.g., this.game.music.volume = 0.5; this.game.music.play('music1'); }, update: function () { this.game.music.update(); }, shutdown: function () { this.game.music.destroy(); this.game.music = null; } }; Link to comment Share on other sites More sharing options...
Zampano Posted August 28, 2017 Author Share Posted August 28, 2017 Thanks for your reply! Unfortunately it doesn't seem to work. The additional Soundmanager is initiated properly and the sound does play, but changing the master volume of this manager doesn't do anything while changing this.game.sound.volume still affects the music. I think I will go with a custom add sound function that also adds the sounds to a directory divided in sfx and music, give each sound a static volume factor and then process this in the runtime together with one master volume variable for each group. Link to comment Share on other sites More sharing options...
Recommended Posts