How do you make music stay in a room...

Started by Jury_Rigged107, Thu 30/07/2015 19:12:46

Previous topic - Next topic

Jury_Rigged107

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


Jury_Rigged107

okay do I start new music in another room?
do I set up background music? something?
anything?

Cassiebsg

#2
From the 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

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... ;)
There are those who believe that life here began out there...


Crimson Wizard

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.

SMF spam blocked by CleanTalk