Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jury_Rigged107 on Thu 30/07/2015 19:12:46

Title: How do you make music stay in a room...
Post by: Jury_Rigged107 on Thu 30/07/2015 19:12:46
I don't know anything about scripting I have figured out some of the basic by trail and error
but if you want music to stop or change if a person leaves the room
how to do it?
is it music.stop if cplayer.chagee room or something?

I need help pls

Title: Re: How do you make music stay in a room...
Post by: Jury_Rigged107 on Thu 30/07/2015 20:01:31
okay do I start new music in another room?
do I set up background music? something?
anything?
Title: Re: How do you make music stay in a room...
Post by: Cassiebsg on Thu 30/07/2015 20:51:20
From the manual (http://www.adventuregamestudio.co.uk/manual/):

Quote
Stop (audio clip)

AudioClip.Stop()

Stops all currently playing instances of this audio clip.

Example:

aExplosion.Play();
Wait(40);
aExplosion.Stop();

plays the aExplosion audio clip, waits 1 second and then stops it again.

Compatibility: Supported by AGS 3.2.0 and later versions.

See Also: AudioClip.Play

Quote
Stop (audio channel)
(Formerly known as StopAmbientSound, which is now obsolete)
(Formerly known as StopChannel, which is now obsolete)

AudioChannel.Stop()

Stops the sound that is currently playing on this audio channel.

Example:

AudioChannel *channel = aExplosion.Play();
Wait(40);
channel.Stop();

will start playing the aExplosion audio clip, wait for a second, then stop it.

Compatibility: Supported by AGS 3.2.0 and later versions.

See Also: Game.StopAudio

So yeah, if your music is called "music",

Then you need:
Code (ags) Select

music.Stop();


Use an IF condition if it's for any other character besides the player. If it's the player that leaves the room then add the code to before fade in in the next room script.

EDIT: Edited the code, to show proper AGS code + link to manual... ;)
Title: Re: How do you make music stay in a room...
Post by: Jury_Rigged107 on Thu 30/07/2015 20:53:48
Thanks!
Title: Re: How do you make music stay in a room...
Post by: Crimson Wizard on Thu 30/07/2015 21:00:40
If you want every room to have its own music, then do this:
1. For every room create "OnLoad" event handler function.
2. In every such function place "aMyMusic.Play()".
By default music has only 1 channel, therefore any new music started will stop previous one.