Sound

Get help using Construct 2

Post » Mon Feb 20, 2012 10:43 am

Hi Everybody!

Is there any way to set the amount of times you can play a sound?

Cheers!

P.s. Need more actions with sound!
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Mon Feb 20, 2012 12:07 pm

what exactly do you mean with amount of times?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Mon Feb 20, 2012 12:15 pm

Hmmm you can always set a timer (global/instance variable) when you play a sound, you increment it and when this timer variable reach a specific value you stop the sound. (But you should preload it first to be sure it's as sync as it can be)
[code]Global number timer = 0
+On what you want
-> Audio: Stop sound tag "mySound" // to stop the sound if you don't want two sounds playing at the same time
-> Audio: Play sound tag "mySound"
-> System: set timer to 5
+System: Every tick
-> System: set timer to max(timer-dt,0)
+System: timer = 0
-> Audio: Stop sound tag "mySound"[/code]
Should workYann2012-02-20 12:16:24
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Feb 20, 2012 12:17 pm

for example:

You press a button, an action begins with sound. Then you cant play the sound again till all other actions have taken place.
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Mon Feb 20, 2012 12:18 pm

@Yann

I will give that ago!
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Mon Feb 20, 2012 12:32 pm

@Yann

Its not working for me, can you show me an image of what it will look like in the engine?
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Mon Feb 20, 2012 12:59 pm

send me a simple .capx with what you managed copy from my solutionYann2012-02-20 12:59:59
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Feb 20, 2012 1:03 pm

so you are trying to play a sound twice or even more at the same time?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Mon Feb 20, 2012 1:08 pm

@Weishaupt

I have a button, you press the button, it plays the sound and something happens next.

I don't want to be able to play the sound again until the rest of the scripts have finished doing what they are doing.

@Yann

Test     
B
5
S
1
G
1
Posts: 111
Reputation: 1,122

Post » Mon Feb 20, 2012 1:09 pm

Ok, now I understand. thx!

You can allways check if the sound is still playing and if so, not start it againWeishaupt2012-02-20 13:10:28
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Next

Return to How do I....?

Who is online

Users browsing this forum: Nifl and 27 guests