Playing sounds randomly?

  • 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!

  • 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.

  • 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

    It would be really big help to me!

  • 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.

  • 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...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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."

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)