Jump to content

Need help with audio volume for preloaded audios


A2020
 Share

Recommended Posts

So, I'm having problems figuring this out.

I was able to control audio volume for audios that I load once the game itself is running, but I don't know how to do it for audios that I load on the preload stage.

For the ones I have working I do something like this, where "audio" is a global variable.

audio = new Audio('assets/ogg/nagg/audio.ogg');
audio.play();
audio.volume = overallVolume;

And a function triggered by buttons with stuff like:

audio.volume += 0.1;
overallVolume = audio.volume;

Now for the audios I "preload" I play them this way, and don't know how would I tweak its volume

(preload)

game.load.audio('wheel', ['assets/ogg/wheel.ogg']);

and to play the sound:

game.sound.play('wheel', 0.4);

So question is, how should I play the preload audios to be able to control the volumes on them?

Link to comment
Share on other sites

I feel silly, sometimes when you end the post you realize the answer is right in front, I did

sound=game.sound.play('wheel', 0.4);

And then changed the sound volume as I was doing with audio.
Leave it here in case someone has similar problems ;)

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...