Getting Room load music

Started by NiksterG, Thu 11/02/2010 19:36:54

Previous topic - Next topic

NiksterG

Hi everyone,

I am returning to AGS after a few years break, and I am amazed at the changes that have happened. I think I can handle most of the bigger changes, but the new audio system is really getting me. I am trying to convert an old version 3.1.2 game to the new 3.2 RC3 version. I am going through all my scripts, and converting PlayMusic(#) to what they are supposed to be. However, there is one point where I coded this:

PlayMusic(Room.MusicOnLoad);

How would you convert this into the new version? Thanks in advance for the help!
Check out my games! (Not all made with AGS)

Crimson Wizard

AFAIK there's no such thing as Room.MusicOnLoad now. You should specify directly which music file you need to play at the room start, or elsewhen/where.
Check audio file names in the Audio subcategory on your project tree.

Syntax is like
Code: ags

aSomeMusic.Play();

NiksterG

I understand the object oriented way of doing it, it's just that I need to know how to implement the Room.MusicOnLoad property if it doesn't exist anymore.

What I'm trying to accomplish is, the player enters the room, and music plays. Sometime while the player is in the room, he clicks on a menu, which opens different music. When the menu is closed, whatever music the room loads with starts over again. Depending on which room the player is in, this could be a different song - so I need the MusicOnLoad property.
Check out my games! (Not all made with AGS)

Crimson Wizard

#3
Hmm, there's a point in this.

I have not much experience using new Audio system, but this is something that comes to mind (there may be better ways, perhaps):

You can use something like an AudioClip array to store room musics.
You will also need an AudioChannel to store menu music state.
Code: ags

AudioClip * RoomMusic[NUMBER_OF_ROOMS_YOU_HAVE];
AudioChannel * MenuMusicChannel;


You initialize array on game start, like:
Code: ags

RoomMusic[1] = aRoom1Music;
...


When menu music is launched you make this:
Code: ags

MenuMusicChannel = aMenuMusic.Play();


Then you can put this into global repeatedly_execute function:
Code: ags

if (MenuMusicChannel == null || !MenuMusicChannel.IsPlaying())
{
   RoomMusic[player.Room].Play();
}



EDIT: Oops, I forgot that room music will need a channel check too:

Code: ags

AudioChannel * RoomMusicChannel;


Code: ags

if ((MenuMusicChannel == null || !MenuMusicChannel.IsPlaying()) &&
     (RoomMusicChannel == null || !RoomMusicChannel.IsPlaying()))
{
   RoomMusicChannel = RoomMusic[player.Room].Play();
}

SMF spam blocked by CleanTalk