Implementing sound during menus

Get help using Construct 2

Post » Fri Jan 18, 2013 5:48 pm

Hi guys,

How do you implement your menu's music?
I want a single sound to play along all my menus, but I'm hitting a wall trying to implement it.

I've tried some ways already, but it won't work out.

It would be really easy if we had an event such as:
If Sound "X" is playing -> Do such.

But we don't right? :(Miyavi2013-01-18 17:50:04
B
6
S
1
Posts: 54
Reputation: 958

Post » Fri Jan 18, 2013 6:05 pm

Well, that was easier than I expected.

You simply need a variable to control it all.
B
6
S
1
Posts: 54
Reputation: 958

Post » Fri Jan 18, 2013 6:35 pm

Care to elaborate? This is something that I plan on doing with my game but hadn't considered that the music would cut out between screens.
B
56
S
15
G
10
Posts: 910
Reputation: 11,972

Post » Sat Jan 19, 2013 3:59 am


Sure:

I have a global variable called "soundPlaying", which is initially set to 0.
Whenever I enter a menu layout, I do the following:

If soundPlaying == 0 -> set soundPlaying to 1, play "menuLoop"

This way, whenever I leave the initial layout, it's always set to 1, and hence, the sound won't overlap itself.

When I go to a Level Layout, as it has a different music loop, I simply stop the menuLoop music.
When the user comes back from the level, I set "soundPlaying" to 0 again, so it starts playing again in the menus.
B
6
S
1
Posts: 54
Reputation: 958

Post » Sat Jan 19, 2013 7:35 pm

Nice one, thanks :)
B
56
S
15
G
10
Posts: 910
Reputation: 11,972


Return to How do I....?

Who is online

Users browsing this forum: ETgirl79 and 12 guests