How do I make a sound not loop but repeat

Get help using Construct 2

Post » Thu Aug 06, 2015 10:44 am

Hi so I want to make a sound pop up when a layer comes visible.

This is somewhat something like a tutorial or explanation. If you pick X or Y or whatever, a layer becomes visible where a character with a text box comes and explain you the mechanic/item/whatever.

I want to to add a sound for when this happens so I figured I would add a sound whenever that layer becomes visible. The problem is if I dont set trigger once while true, the audio loops as long as stays visible and if I trigger it, works fine but only happens the first time the layer becomes visible and I want it to happen everytime.

Long story short: I want a sound to pop up when a layer becomes visible, just play ONCE at the start, do not repeat as long as is visible and I want it to happen every time the layer becomes visible.

Any ideas?
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Thu Aug 06, 2015 11:31 am

You need an instance variable. Set it to boolean. Toggle it from false to true when the layer is visible and back to false when invisble. Make it that the sound only plays when said variable is false. That should make the "trigger once while true" obsolete.
B
10
S
4
G
2
Posts: 117
Reputation: 1,872

Post » Thu Aug 06, 2015 2:06 pm

I'm not sure how to do what you're saying. I've set up this:

If layer X is visible set to true
If layer X is not visible set to false.

I can't seem to find any condition to run if boolean is A do B. The system variables are only available for globals not instance. Sorry if I make stupid questions but I lack a lot of knowledge.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Thu Aug 06, 2015 8:12 pm

Anyone? Please :P
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Fri Aug 07, 2015 10:54 am

Ok, here we go. This should do the trick:

Image

The player object gets the boolean "hintVisible". Set it to false. The layer "hint" is only visible when this boolean is true. It is toggled by hitting the blue collision object. Then a counter with a global variable starts. After 6 seconds (adjust it to your needs) the boolean is toggled to false, the layer becomes invisible and the player can hit the collision object again repeating the procedure. Since "on collision with object" is identical to "trigger once while true" the sound is played once when toggeling the boolean.
B
10
S
4
G
2
Posts: 117
Reputation: 1,872

Post » Fri Aug 07, 2015 9:29 pm

That doesn't work for my case. I do not want any countdown and I need to set it as a layer is visible not as an object with collision. That's exactly the problem.
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Sat Aug 08, 2015 1:45 pm

Hi so I want to make a sound pop up when a layer comes visible.
That was your problem. My setup solved this problem. Have you at least tried it out?

The layer "hint" becomes visible when hitting the collision object - a sound is played once. You can replace the condition on collision with object with what ever you want. The counter is just for making the layer invisible again so the procedure can be repeated. You can also replace this mechanic with whatever you want.
B
10
S
4
G
2
Posts: 117
Reputation: 1,872

Post » Sat Aug 08, 2015 3:20 pm

Hello liquidmetal. I tried it and didn't work out for the kinda of effect I was looking for. Somehow I managed to pull it off in other way that suits me better.

Thank you very much for your kind help, is been helpfull regardless :P
B
14
S
5
Posts: 248
Reputation: 1,705

Post » Wed Aug 12, 2015 10:38 pm

I'm having a similar situation
B
32
S
9
G
3
Posts: 280
Reputation: 4,262

Post » Wed Aug 12, 2015 10:47 pm

couldnt you just trigger the audio in the same place you're displaying the layer?

- when something happens
- display layer
- trigger audio once

...?

edit: like @liquidmetal's solution haha
Made Cosmochoria - www.cosmochoria.com
Currently working on Slayaway Camp - www.slayawaycamp.com
B
27
S
8
G
3
Posts: 384
Reputation: 5,020

Next

Return to How do I....?

Who is online

Users browsing this forum: YoHoho and 15 guests