Is there an easy way to fade in/out the audio clips?

Hi everyone!

Short question to ask about the current audio engine. Is there any way to fade in/out the audio clips on play/stop other than maybe manually tuning the volume?

I have a case in my game where I play continuous looping sound from a gadget. However this sound starts from the default volume levels and when I stop it, the sound is instantly gone. Would be really cool to start looping the sound from zero volume and move it to default volume, and on reverse when stopped :slight_smile:

Do you guys have any suggestions how to implement this or is there an easy function available that I am not aware of? Cheers! :sunglasses: :pray:

There is a setting for the gain. You might transition it to zero to fade out. The Sound class might use the term volume for the gain. Check docs or source file. This can be done.

1 Like

setVolume is what you need:

Use something like setVolume(0, 2) to fade the sound out after 2 seconds.

2 Likes