In one of my rooms, I want to have some music. In the interaction room, before fadein, I write the following code:
SetMusicRepeat(1);
SetMusicMasterVolume(50);
SetMusicVolume(3);
PlayMusic(0);
In the end interaction of the room I stop the music
Everything is ok, but the music starts every time I start the game, even if I start in another room. I must enter in the room with music and then get out to stop the music (with the commands that I write there). Why is the music allways starting at the beginning of the game ?
Because you told it to.
If you want it to start just once put those into the "...enters room (for the first time)" event instead.
I was not very clear. I write this code in room 32. Then I start the game. The game start in room 3, but with the music from room 32. I go in room 32, then get out and the music stops. From this point, everything is ok.
If I put music in all 32 rooms, that means that when I start the game, I will have 32 songs simultaneousy ?
That's because the music is #0, which will be played automagically whenever the game starts. This is by design.
Change that to music1 or some other numbers.
OK !!!! That is not very nice from the AGS !
PS. This is written somewhere in the help, taht music #0 start when the game start ? If yes, stupid me.
Thank you ! :D
Yes, though it's not very obvious:
Other Features -->
Music and soundQuote
When the game loads, music 0 will be played if it exists in the "Music" directory. You can change the music later by setting "Play music on room load" in a room, by using the PlayMusic script command, or by using the "Play music" interaction command.
It was historical, that in AC era, CJ tried to make the engine easy to use, ie. you could make simple games just with the legendary Graphical Script and some of the stuff would be done
automagically by the engine, that included, a theme music which will be played whenever the game starts (as long as there's a file of supported formatÃ, named music0). However, turned out this is not very useful, so this is not a recommended feature, and it's advised that you don't use #0 for music (unless you
really need that).