Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Playing different music in different areas
Tony32 Offline
Junior Member

Posts: 26
Threads: 2
Joined: Jan 2011
Reputation: 0
#1
Playing different music in different areas

Hello again, yet I've stumbled on another problem. This time I'm wondering how the music playing really works for different rooms. I've read that the built in sound in the level editor is bad for this task, so I guess I'll have to do it using scripts.

How is it supposed to work? Create one area for each room and play sounds if they are in it? How am I supposed to loop the sounds while the player is inside the area? Also, which function to play the music should I use? PlayGuiSound or PlayMusic?
Ex.
If (insideKitchen)
play sound X

If(InsideHallway)
play sound Y

Is it supposed to be like that or have I got it all wrong? x)

Thanks in advance ^^
01-11-2011, 09:02 PM
Find
ModManDann Offline
Member

Posts: 61
Threads: 6
Joined: Dec 2010
Reputation: 0
#2
RE: Playing different music in different areas

I think you'd have to create area's and add a collide call back (for the player and the area) and in this call back use the following function:

PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

Current project: Mind Trap
01-11-2011, 10:59 PM
Find
Andross Offline
Junior Member

Posts: 38
Threads: 1
Joined: Oct 2010
Reputation: 0
#3
RE: Playing different music in different areas

I would use collision callbacks for the areas surrounding rooms.
AddEntityCollideCallback("Player", "RoomArea1", "OnCollideRoom1", false, 0);
Then, start or stop the according music.
void OnCollideRoom1(string &in parent, string &in child, int state)
{
    if (state == 1) // start
        ....
    if (state == -1) // stop
        ....
}
The functions for the music would be PlayMusic() and StopMusic(). Music sounds should loop automatically until they are stopped explicitly.
(This post was last modified: 01-11-2011, 11:07 PM by Andross.)
01-11-2011, 11:06 PM
Find
ModManDann Offline
Member

Posts: 61
Threads: 6
Joined: Dec 2010
Reputation: 0
#4
RE: Playing different music in different areas

music stops if another music starts to play, so there's no need to stop the music everytime. Just start a new one.

Current project: Mind Trap
(This post was last modified: 01-12-2011, 02:00 AM by ModManDann.)
01-12-2011, 02:00 AM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#5
RE: Playing different music in different areas

(01-12-2011, 02:00 AM)ModManDann Wrote: music stops if another music starts to play, so there's no need to stop the music everytime. Just start a new one.

Depends on alPrio.


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
01-12-2011, 03:20 PM
Find




Users browsing this thread: 1 Guest(s)