Hello! I apologize if my question is stupid. But really i'm a noob at scripting, i tried to read in the manual but i can't solve it.
Fell free to insult me, i'm new with AGS :smiley:
i Wanted the music to change every time you get to a different room, so using a specific music for each room, but the game only plays the first one for the starting room in each of them.
This are the scripts i made:
script for music 1 for the starting room
function roomAfterFadeIn()
{
aMusic1.PlayFrom(1000);
if (aMusic1.IsAvailable)
{
aMusic1.Play();
}
}
script for room2 and its own music. Here the music remains music 1 and nothing changes
function roomAfterFadeIn()
{
aMusic1.Stop();
aMusic3.PlayFrom(1000);
if (aMusic3.IsAvailable)
{
aMusic3.Play();
}
}
thank you very much! :smiley:
You can't just copy/paste into the scripts, you need to open the room, click on events and then click on the "room after fade in" to create a link to the code. ;)
I'd like to point out that if you reserve strictly 1 channel for Music audio type in the editor (I think this is done by default), then you do not have to command "music.Stop", it will be replaced by new music automatically.
You don't need the IsAvailable check, and you really don't need to play it twice.
In each room, add the "before fadein" event, this will create and link the room_Load function. In that function, simply add
aMusic1.Play();
If you have properly imported the audio files into the Music folder, playing a new audio file will stop the currently playing one (since there's only one available channel by default).
thank you very much to everybody! it worked! :smiley: