How do I repeat a sound?

Just started using Construct 2? Post your questions here

Post » Mon Sep 26, 2016 4:35 pm

Posted this on the "How do I ..." forum but havent gotten any replies. Hope Im not breaking any rules by posting it here too.
I'm having trouble getting an explosion sound to play from start to finish, pause for a second or two and then play thru again. Would like to do the same thing with the matching explosion animation. I can do it one anim+sound at a time with a button click, but I would like it to start and then repeat itself perhaps 2-4 times without player clicking a button. Any suggestions?
B
9
S
3
Posts: 31
Reputation: 708

Post » Wed Sep 28, 2016 1:49 pm

Could you not just copy/paste the explosion event and sound triggering event triggered once, twice with a 2 second wait between?

If its a random 2-4 times you could nest them under a primary variable testing event that got a number and then filtered any remaining times with else condition...

ie. something like:
times=choose(0,1,2,3)
play explosion event
play sound event
if choose = 0
play explosion event
play sound event
else if choose = 1
play explosion event
play sound event
wait 2
play explosion event
play sound event
else if choose = 2
play explosion event
play sound event
wait 2
play explosion event
play sound event
wait 2
play explosion event
play sound event
else if choose =3
play explosion event
play sound event
wait 2
play explosion event
play sound event
wait 2
play explosion event
play sound event
wait 2
play explosion event
play sound event

I am sure it could be written much more efficiently.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Thu Sep 29, 2016 11:54 am

You can put the [play explosion event] and the [play sound event] in a function and you repeat this function 4 times (with a delay).
B
12
S
7
G
4
Posts: 114
Reputation: 3,067

Post » Thu Sep 29, 2016 1:13 pm

Thank you, guys. Both work for me. Good learning experience.
B
9
S
3
Posts: 31
Reputation: 708


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest