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

Get help using Construct 2

Post » Wed Sep 24, 2014 4:50 pm

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.
B
12
S
2
Posts: 36
Reputation: 1,949

Post » Thu Sep 25, 2014 12:38 am

Give it a different tag.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Post » Thu Sep 25, 2014 2:32 am

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.
B
45
S
23
G
31
Posts: 691
Reputation: 20,608

Post » Thu Sep 25, 2014 2:55 am

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.
Founder of Jadelight Studio, Developer of Libertas Aedifex, regular C2 Help contributor and fan of ambient music and Star Wars.
B
12
S
4
Posts: 255
Reputation: 2,008

Post » Thu Sep 25, 2014 1:47 pm

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 * ?
B
12
S
2
Posts: 36
Reputation: 1,949

Post » Thu Sep 25, 2014 2:11 pm

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)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Sep 25, 2014 4:12 pm

@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 :\
B
12
S
2
Posts: 36
Reputation: 1,949

Post » Sun Sep 28, 2014 6:34 pm

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. :(
B
72
S
21
G
12
Posts: 314
Reputation: 12,111

Post » Sun Sep 28, 2014 7:04 pm

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)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Sep 29, 2014 12:30 am

Using the same tag for everything defeats the purpose of tags. And you control the global volume without having to reference tags.
B
56
S
15
G
13
Posts: 826
Reputation: 17,645

Next

Return to How do I....?

Who is online

Users browsing this forum: amazingdream, lordsas, mekonbekon and 50 guests