Playing sounds randomly?

Get help using Construct 2

Post » Tue May 13, 2014 12:13 am

How can set if ihave 5 sounds to playing it randomly sequentially???

So i have:
S1, S2, S3, S4, S5

I want to play these randomly automatically one after the other when i touch "play" button: S1, S2, S5, S1, S3, S2, S4, S1, S5, S2, S5......
And if i restart it and touch play button again the sounds should play on other way (this how i mean randomly)

Thanks!
B
4
Posts: 29
Reputation: 262

Post » Tue May 13, 2014 1:38 am

You need to add the "Play (by name)" action and on the "Name" field type either "S & round(random(5))" or choose("S1", "S2", "S3", "S4", "S5") and give it a tag name

Don't forget to add the "On Ended" condition and add the tag name you just gave.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue May 13, 2014 2:05 am

It's easier than I thought, thanks!

So this is more difficult i think:
If i have 5 sound and 5 picture:

S1, S2, S3, S4, S5
P1, P2, P3, P4, P5

S1 fit to P1, S2 fit to P2 etc.

If i touch "play" button randomly start one of the sounds...
if S1 started i have to touch P1 while sound is playing and then i get 1 score and an another sound starts randomly and it goes on like this BUT if i touched other picture (P2, P3, P4 or P5) OR the first sound is ended the game over (destroy all picture for example)

(After i touched the right picture and an other sound get started for example S3, i can't touch P1 anymore because as i wrote i have to touch the picture that fits to right sound)

I can not figure out how can i do this :shock: :?:

It would be really big help to me!
B
4
Posts: 29
Reputation: 262

Post » Tue May 13, 2014 12:31 pm

I am sorry, I can't find a way to "connect" sounds with sprites and update the remaining choices. The problem is getting the sounds (and the corresponding cards) that are already picked out of the equation.
I think you need arrays but I don't understand arrays. :(
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Tue May 13, 2014 2:52 pm

I think I understand what you mean.

You press play. A random sound plays among the 5 sounds you have.

Then Sound 3 plays, you have to click Card 3. If sound ends, you loose.

You do it like this:

Global Numbers variables:
S1 / P1 / S2 / P2, etc... to 0 each
You need to set tags in your "Play" sounds.

On S1 stops playing: if P1 = 0 then player loses. if P1 = 1 play next random sound and set P1 = 0.

On P1 clicked:
If S1 is playing: Set P1 to 1.

On P2 clicked:
If S2 is playing: Set P2 to 1.

etc...
B
17
S
3
G
3
Posts: 89
Reputation: 2,825

Post » Wed May 14, 2014 2:06 am

Hmm Thank you, but can you explain it better how can i set these?

"Global Numbers variables:
S1 / P1 / S2 / P2, etc... to 0 each
You need to set tags in your "Play" sounds.

On S1 stops playing: if P1 = 0 then player loses. if P1 = 1 play next random sound and set P1 = 0."
B
4
Posts: 29
Reputation: 262


Return to How do I....?

Who is online

Users browsing this forum: Cubeeo, Yahoo [Bot] and 16 guests