How do I make a sound repeat?

Get help using Construct 2

Post » Sun Sep 25, 2016 8:09 pm

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 a perhaps 2-4 times a few seconds after 'on end of layout' without player clicking a button.
Posts: 31
Reputation: 708

Post » Tue Sep 27, 2016 4:19 am

I have a few question what is the logic in getting 2 ,3 or 4 times. is it random or is it based on condition of the result of your game.

And right you you can do function such as on end of layout do function

and then repeat (callback variable)
do what you want to do.

Or you can use Timer here

on end of layout. choose 2,3,4 for a global variable
Start timer

and do during timer do the action

When timer expire substract one

if compare two value

First value is global variable is equal 2nd value (0) end the game
else start timer.

This should work if it doesnt then i do not know how you are running your game.
Posts: 391
Reputation: 7,855

Post » Tue Sep 27, 2016 4:42 am

You can use the function object to help you with this. Create a function called "Explosion" which takes the number of explosions as a parameter.
On Function "Explosion"
For Loop, repeat Function.Param(0) times -> play explosion animation -> play explosion sound
if Function.Param(0) > 1 -> wait 1 second

When the player clicks:
on click -> Call Function "Explosion" with one parameter =1
This will play the explosion one time

At the end of layout -> Call Function "Explosion" with one parameter= 10
This will make 10 explosions (and so on).
Posts: 97
Reputation: 6,614

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests