How do I stop a sound that share same tag of others

0 favourites
  • 12 posts
From the Asset Store
75 explosion sound effects. Essential for many games, Explosions Sounds contains a mix of explosion and impact sounds.
  • I'd like to know if it's possible to stop a sound without using its tag because it's used in other sounds.

    I've multiple sounds with "sfx" tag, so I can increase or decrease the volume using "sfx" tag, but in some situation I'd like

    to stop 1 sound only.

    Example: a mosquito flying and looping sound "fly.ogg" with "sfx" tag. it dies and I need to stop "fly.ogg" and play "death.ogg",

    both sounds having "sfx" tag.

    Is there a way to accomplish this task? Or I need to wait for multiple tags/audio families from Ashley?

    Thanks in advance, and forgive me for my bad english.

  • Give it a different tag.

  • As troublesome as it might seem, giving each a different tag now is the best approach I think. Tags are used mostly to call individual sound files, not group them together.

  • Agreed with all of the above. Give each a different tag, but use sfx_ as a prefix so you have sounds like sfx_bullet, sfx_movement, etc. Then they're categorised for easy reading but unique and selectable.

  • Thanks, but I'd like to keep the same tag on all sounds, so I can use a slider to increase/decrease volume by tag.

    Otherwise I'm forced to write lots of action only to change volume of sounds one by one :

    Maybe tags accept wildcard like * ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure, but if the tag is a string, wouldn't it be possible to just compare the first part of the string with something like TokenAt or another string comparison expression? (Just thinking out loud, so might be completely wrong)

  • LittleStain : great idea, but it doesn't work.

    Example: 2 sounds with similar tag

    1) fly.mp3 ("sfx_fly")

    2) death.mp3 ("sfx_death")

    when I need to set volume, the action is "Set (tag) volume to (value)"

    so I can't say "Set (first 3 char of.... ??? ) volume to 5"

    because tags are not variables I have access to.

    Maybe I'm wrong, so I hope anyone can help me about this :\</p>

  • Very interesting problem as there's only one tag available by object.

    In your case (if I got it right), a solution would be to create a Global variable for the Volume.

    Then use that variable to set the volume of each sound concerned by that option. (instead of "0" you put the variable)

    The tag is free for anything else.

    The problem is that you need to replay a sound to apply the new volume. (which is not really a issue if it's done on an "options layout" for example)

    I don't see any other solution for now.

  • Would using an array to store the tags work?

    set the first row to sfx and the second to the tag

    if array.at(currentx,0) = sfx

    • set audio with tag (array.currentx,1)
  • Using the same tag for everything defeats the purpose of tags. And you control the global volume without having to reference tags.

  • play flying

    stop(no tag) stops last played sound.

    play death

    we have play filename

    we should have stop file name as well.....

    That workaround should work i think.

  • thanks everybody for the help. Similar to LittleStain, I made an array with all sound tags and change volume using 'For Each element' of the array.

    Tekniko I think you're wrong (in part) because in the Audio section of the manual you can read this: 'Multiple sounds can also play at once using the same tag. In this case actions like Set Volume affect all the sounds playing with that tag' , and that's what I'd like to achieve. Futhermore I can't decrease master volume without affecting BGM volume so it's useless to my purpose.

    Again, thanks to everybody for the help and I think Ashley can close the topic

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