How do I setup same song for all levels

Get help using Construct 2

Post » Fri Sep 19, 2014 2:07 pm

Hi guys,

I have a little problem with the audio of my game.

1. I have several layouts called menu, levels, tutorial (with his own music) and level 1, level 2 (with a different music).
2. Each time I start a level, the audio begins with "On start of layout".
3. Each time the character dies, the layout (level x) restarts with "Reset layout", therefore the audio overlaps the originally started with the layout. I have "solved" this with Audio "Stop all" every time the character dies, but the song starts again from the beginning.

I want to put a single song for all levels and would be nice if it stop restarting each time the character dies and every time you go to next level. Something like a global song for all level layouts only.

How can I solve this?

Regards, Leonard.
B
7
S
1
Posts: 5
Reputation: 396

Post » Fri Sep 19, 2014 3:16 pm

you can add tags to the audio and check if it's play or not
on start of layout
if tag "musicLevel" not playing
play audio with tag "musicLevel"

you can add a var to it for the levels
tag "musicLevel"&level
Image
B
78
S
29
G
12
Posts: 515
Reputation: 12,559

Post » Fri Sep 19, 2014 3:27 pm

Lof wrote:you can add tags to the audio and check if it's play or not
on start of layout
if tag "musicLevel" not playing
play audio with tag "musicLevel"

you can add a var to it for the levels
tag "musicLevel"&level


Yes, i was thinking about your first solution when the player dies, but i don't really know how to check if its playing or not.
B
7
S
1
Posts: 5
Reputation: 396

Post » Fri Sep 19, 2014 4:13 pm

add event -> audio -> is tag playing
"If you want to move a mountain tomorrow, you should start by lifting stones today."
B
64
S
14
G
2
Posts: 291
Reputation: 6,666

Post » Fri Sep 19, 2014 5:51 pm

puntodamar wrote:add event -> audio -> is tag playing


I can try that, but when the tag is playing, if the layout restarts and I set "Stop" then it stops all the music.
You do not have the required permissions to view the files attached to this post.
B
7
S
1
Posts: 5
Reputation: 396

Post » Fri Sep 19, 2014 5:58 pm

No you didn't understand what i meant,
click on the audio is playing condition than click on "i" on the keyboard, this will reverse the event to checking false condition.
delete the stop action
and move the play action to the sub event

now only if music is not playing the action will be called.
Image
B
78
S
29
G
12
Posts: 515
Reputation: 12,559

Post » Fri Sep 19, 2014 6:32 pm

Lof wrote:No you didn't understand what i meant,
click on the audio is playing condition than click on "i" on the keyboard, this will reverse the event to checking false condition.
delete the stop action
and move the play action to the sub event

now only if music is not playing the action will be called.


Awesome ! That worked like a charm for the deaths, now I must try something for the other levels.

Thank you Lof !
B
7
S
1
Posts: 5
Reputation: 396

Post » Fri Sep 19, 2014 6:35 pm

as i said before, have a var named level
and check in the tag
if music&level is not playing
stop all
play "music"&level with tag "music"&level

than if you die and restart the same level the event will not be called.
and if the level changes the music will stop and play the new music with a new tag
Image
B
78
S
29
G
12
Posts: 515
Reputation: 12,559

Post » Fri Sep 19, 2014 6:45 pm

Lof wrote:as i said before, have a var named level
and check in the tag
if music&level is not playing
stop all
play "music"&level with tag "music"&level

than if you die and restart the same level the event will not be called.
and if the level changes the music will stop and play the new music with a new tag



Absolutely stunning skills :p thank you so much !
B
7
S
1
Posts: 5
Reputation: 396


Return to How do I....?

Who is online

Users browsing this forum: bclikesyou, kalibark2 and 34 guests