How can i fade music in and out smoothly ?

For example when i go from start menu to level 1 i want the music that was on the start menu to slowly drift away while the new one which is on level 1 to start raising up … stuff like that … can this happen ?

1 Like

Before switching to the next scene add an event like this:

Conditions: Variable level_finished is = 1 Actions: Do - 30*TimeDelta() to the music volume
It means after the level has been finished (you’ve to flag it someway, I do it with a “level_finished” variable), keep subtracting 30 units per second to the music volume (if I’m right the volume goes from 0 to 100, so it will totally fade out after 3.33 seconds), if you want to add a black screen fade out you can do the same in the same events but adding X*TimeDelta() to the opacity of a black masking sprite with opacity=0 initially.

Then add an event like this:

Conditions: Music volume is <= 0 Actions: Change to the scene "NextLevel"
After totally fade out change the scene.

And finally in the next scene:

[code]Conditions: At the beginning of the scene
Do = 0 to variable level_finished
Actions: Play music “NextMusic” with volume 0

Conditions: Variable level_finished is = 0
Actions: Do + 30*TimeDelta() to the music volume[/code]
At the beginning play the new music with volume 0 and increase it over time. You can add the same code of the other scene here to make this one also fade out.

1 Like

Alright cool … i get it now . i will try it now and if something comes up i post about it . Thanks a lot .

Lizard-13 it worked just as i needed … thanks again :slight_smile: