How do I loop my music forever

Get help using Construct 2

Post » Thu May 22, 2014 3:17 pm

I want my music to always loop regardless of anything, but whenever the layout starts or changes the music starts again, any help?
B
6
S
1
Posts: 69
Reputation: 643

Post » Thu May 22, 2014 3:27 pm

play the music in a blank layout only for sound maybe ?
B
4
Posts: 10
Reputation: 222

Post » Thu May 22, 2014 3:35 pm

You can use the tag in the music option for this. Whenever you play music, it gives you the option to place a tag to it. Than you could just use the tag to check if the music is playing.

For example: Let's say your Music is titled "Music1", you can place in the tag section "Music1"

Audio, If tag "Music1" is not playing (you need to select the playing tag and invert it)
Trigger once:
.....Audio Stop All
.....Audio play Music1 lopping at volume -0db (tag "Music1"

This way it detects if there is no music playing (first time) it will play the music, than each time you go back, since the music is still playing, it will not restart the music.
B
42
S
21
G
31
Posts: 685
Reputation: 20,321

Post » Mon May 26, 2014 10:53 pm

Dear all, I am struggling to find a solution: to have continuous music playing across different layouts.

Is it possible to play a continuously looping track (tagged music) across different layouts or - as I am beginning to suspect - will the track have to be restarted upon a change of layout? This is a bit irritating because I want to have the same music track continue to play on layout 1 and layout 2; at the moment the music does not play if the layout is changed and it has to be restarted - this could be a few seconds after the game has started and looks (sounds) a bit unprofessional.

Thanks for any help.
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193

Post » Tue May 27, 2014 3:31 am

So.... Without changing anything, apart from doing a restart of C2, it all works as expected now...
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193

Post » Tue May 27, 2014 5:38 am

@Colludium, it should be able to play the same music across different layout, at least that is how it worked with my game.

All I did was use the code I showed above. From my testing, C2 will continue to play the same track until it is told to stop. So if the start of your layout doesn't ask your music to stop, it should continue playing.
B
42
S
21
G
31
Posts: 685
Reputation: 20,321

Post » Tue May 27, 2014 9:29 am

Start of layout
.. Audio: X (inverted) Is "Music" Playing ? => Audio: Play your-music-file tag: "Music"

Have this in your common event sheet or as Start of layout event for all your layouts event sheets, and it will do the job.
It will only try to play the music when, on start of layout, the song isn't already playing.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,319
Reputation: 87,487

Post » Tue May 27, 2014 10:38 am

Kyatric I was looking for this thanks
B
245
S
39
G
15
Posts: 1,945
Reputation: 40,264

Post » Tue May 27, 2014 11:25 am

@Kyatrik & @rekjl - thanks for the replies. This is a bit hard to explain because I had it all set up correctly, indeed I've not had trouble doing this before on other games, but I couldn't get it to work this time around for some reason. I just wanted to see of anyone else was having the same problem because i was beginning to think it was a bug or possibly my own incompetence (I'm using r170 but I know that the audio plugin has not been touched...). Then I restarted C2 and the music now plays correctly....
I only occasionally visit - I'm learning C# for Unity, but c2 is still a respectable game engine imo....
B
73
S
19
G
66
Posts: 2,198
Reputation: 42,193


Return to How do I....?

Who is online

Users browsing this forum: vegapomme27 and 10 guests