Jump to content
SettReznov

Random sound

Recommended Posts

I'm developing a children's game, a mobile with several animal sounds and songs, however, I have a main button that should play several random sounds, every time I click this button, I need to play a different sound, but I tried to All forms, but I can not. Does anyone have any ideas?

 

Edit: I just realized that I started this post in the wrong place. The correct would be for "support Construct2"

Edited by SettReznov

Share this post


Link to post
On 9.2.2017 at 2:40 AM, SettReznov said:

I'm developing a children's game, a mobile with several animal sounds and songs, however, I have a main button that should play several random sounds, every time I click this button, I need to play a different sound, but I tried to All forms, but I can not. Does anyone have any ideas?

 

Edit: I just realized that I started this post in the wrong place. The correct would be for "support Construct2"

Hi :)

that's not difficult. Just name your sounds like

animal_1, animal_2 and so on.

then add an event like:

"On touched button" - Audio - Play audio by name "animal_" & round(random(1,x))

// while x is the higest sound number

Regards Andy

Share this post


Link to post

Hello, thank you for replying.

This works perfectly. Thank you

I just wanted to know how I make one sound not overlap the other. If I press the button several times, I'll have several ringing sounds. I have a sound of 3 seconds, if I then press again, I'll hear the other sound and a small piece of the previous sound. Is it possible for me to make the previous sound stop when I press the button again?

Edited by SettReznov

Share this post


Link to post
2 hours ago, SettReznov said:

I did, though I do not know if this is the correct form.

Each time I click the button, the previous sound for and the next one begins, so no sound overlaps the other.

Capturar.PNG

Hi,

just add a condition like "Is any audio playing" and invert it.

is_any_playing_audio.png

You also can add a specific tag (or more tags). Like !"Is playing "sound_1".

Regards

Andy

Share this post


Link to post

Thank you, this works.
I just noticed that in this way, I can not get the other sound until the previous one ends. But I am satisfied with this mode.

I'm learning a lot here in the forum, before I was only able to edit games that I bought, now I'm starting to create my games.

  • Like 1

Share this post


Link to post
On 16.2.2017 at 10:25 PM, SettReznov said:

Thank you, this works.
I just noticed that in this way, I can not get the other sound until the previous one ends. But I am satisfied with this mode.

I'm learning a lot here in the forum, before I was only able to edit games that I bought, now I'm starting to create my games.

I'm glad to hear that, let me know if you need further help :)

Share this post


Link to post

In another game I'm creating, I created a button to turn off the music and also the sound of the bladders, leaving only the animation of the bladders going up. The music is working perfectly, however when I click to stop the sound of the buttons, I still hear a "little crackling", I do not understand why the sound of the bladders does not completely disappear. Have you ever had this problem? You can look at the game here.

 

Share this post


Link to post
22 minutes ago, SettReznov said:

In another game I'm creating, I created a button to turn off the music and also the sound of the bladders, leaving only the animation of the bladders going up. The music is working perfectly, however when I click to stop the sound of the buttons, I still hear a "little crackling", I do not understand why the sound of the bladders does not completely disappear. Have you ever had this problem? You can look at the game here.

 

Hi,

I couldn't notice this "little crackling" in your demo. Maybe it's something the device is doing?

 

Regards

Andy

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy, Terms of Use, We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. & Guidelines.