Music without interruption?

Get help using Construct 2

Post » Sat Sep 07, 2013 7:46 am

Is there any way to keep the background music playing all the time..? I mean, that I have a project which restarts the layout whenever player misses the target and when player hits target, it goes to next layout.. I would like the music to play without interruptions between layouts and/or restarts..

Thanks!!
B
10
S
3
Posts: 27
Reputation: 1,381

Post » Sat Sep 07, 2013 8:59 am

@chef,

You can use a global variable (musicOn) for this. Just set an event on start of layout to check this variable. If it's 0, then start the music (and set musicOn to 1).

Copy the event to every layout (or put it on a global event sheet), and once you've started the music it will just keep playing. Each time you go between layouts or restart a layout, it will check to see if music is already playing, and take appropriate action.

Edit: Don't forget to reset musicOn to 0 when you finally turn the music off though!

Hope that helps :)Blacksmith2013-09-07 09:02:16
B
33
S
6
G
7
Posts: 494
Reputation: 8,252

Post » Sat Sep 07, 2013 12:57 pm

Ah, yes.. simple as always! Thank you!
B
10
S
3
Posts: 27
Reputation: 1,381

Post » Sat Sep 07, 2013 1:57 pm

@blacksmith

Hmm.. well it wasn't so simple or I'm doing it wrong..




This still starts the song from the beginning when the layout restarts or a new layout starts..chef2013-09-07 13:58:48
B
10
S
3
Posts: 27
Reputation: 1,381

Post » Sat Sep 07, 2013 2:32 pm

Hi @chef,

I've made a simple example of what I was suggesting. You were on the right track, just needed a few minor changes :)

The red button switches between layouts, and the blue button stops the music. You'll notice that when you switch between layouts, the music continues to play without stopping then restarting (because of our variable check)! However turning off the music, sets the variable back to 0, so when you switch to another layout, the music will restart again!

MusicOnOffExample

Music was supplied by @tulamide :) You can find more free music by tulamide here.

Hope that makes things a little clearer :)
Blacksmith2013-09-07 14:38:39
B
33
S
6
G
7
Posts: 494
Reputation: 8,252


Return to How do I....?

Who is online

Users browsing this forum: Construct Monkey, shawnzien, tatogame and 5 guests