Starting and Stopping Ambiant Sound from Room to Room

Started by Ghostlady, Sun 27/07/2008 06:04:38

Previous topic - Next topic

Ghostlady

I would like to carry over a sound effect from room to room (3 rooms) without it stopping and starting.  I want to use ambiant sound so that is does not stop at end but rather loops.  For PlayAmbiantSound - The manual states:

NOTE: The sound will stop when the player leaves the room, unless the game.ambient_sounds_persist variable is set to 1.

Can someone tell me how to set this and then turn it off when I am done with the 3 rooms?  I keep getting syntax errors.

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Khris

Inside the game_start function, put
Code: ags
  game.ambient_sounds_persist = 1;


In the last of the three rooms, add a RunScript action to the Leaves Room event, then put
Code: ags
  game.ambient_sounds_persist = 0;
inside.

Ghostlady

So that would mean any room where I am using ambiant sound, prior to these three rooms, I would have to add game.ambient_sounds_persist = 0; since it will be set to 1 when the game starts?  But then I would be shutting it off before I get to the three rooms I want it for.  Actually as I am typing this, I just realized I can make it a music file instead and I won't have this problem.  I am still currious though how to make it work.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Khris

If there are rooms before the first of the three, don't turn it on in game_start but e.g.in the first ambient sound room's before fadein.
And of course you wouldn't have to put the line in every room prior to the three ambient sound rooms. Turning it on/off once each time is enough.

game.ambient_sounds_persist is a global variable keeping it's value throughout any room changes, unless it is changed.

Ghostlady

That's what I originally did but I get this error on the "leave room".

room70.asc(9): Error (line 9): '.ambient_sounds_persist' is not a public member of 'Game'. Are you sure you spelt it correctly (remember, capital letters are important)?

My code:

  Game.ambient_sounds_persist = 0;

But I know what the problem is, I was using "Game" instead of "game".  Once I changed that it worked.  What is the difference between the capital G and the lower case "g"?
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

Khris

Game. is used for main game related functions and several mostly read-only properties like Game.CharacterCount.

game. is used for all kinds of "special" variables used to tweak engine settings.

You could say the average beginner will hardly use any game. stuff but certainly several of the Game. functions.

In technical terms, Game is a static instance, the game core, if you will, while game is a struct used to group together most of the settings variables.

Ghostlady

Ah, and this is very good information.  Thanks for your help.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven
Haunting at Cliffhouse

SMF spam blocked by CleanTalk