Discuss Scratch

riffsix
Scratcher
16 posts

How do i stop sounds in only one sprite?

I want the player to be able to switch between three mechanisms, each one with its own unique white noise that's supposed to drone on until it's turned off or another is switched on. The problem is that the way i have it coded, switching to another device causes BOTH sounds to play simultaneously and turning devices off only MUTES the sound instead of stopping it altogether. I can't use the “stop all sounds” block, because that removes the background music and might stop some very important sounds from playing. Is there any way i can fix this without having to split the mechanisms into three separate sprites?
mstone326
Scratcher
1000+ posts

How do i stop sounds in only one sprite?

You could create a clone that plays the sound and when the button is clicked to turn it off, delete the clone and its sound will stop playing.

See if this helps.

https://scratch.mit.edu/projects/319791773/


edit:
also created a version using only 1 sprite if you are comfortable with cloning.
https://scratch.mit.edu/projects/319797332/

Last edited by mstone326 (July 4, 2019 17:44:50)

riffsix
Scratcher
16 posts

How do i stop sounds in only one sprite?

Thank you so much! It took a bit of fiddling around, but I got it to work with all three mechanisms without compromising the original functions of the sprites! Your advice was very helpful!
GABOCSB18
Scratcher
28 posts

How do i stop sounds in only one sprite?

You could have a variable called “sound playing?” so when a button is pressed or it receives a broadcast or whatever, it get's set to true. And when the other button is pressed, it gets set to false. Like this:
when I receive [ Change sound]
set [ sound playing?] to [true]

when I receive [ Change other sound]
set [ sound playing?] to [false'


Then you have a script like this:

if <[sound playing?] = [true]> then
set volume to (100) %


else
set volume to (0) %
end


and you just have the sound playing forever on a loop. It may not be the most efficient way. But it works!

Last edited by GABOCSB18 (Dec. 28, 2020 22:50:09)

bake121
Scratcher
92 posts

How do i stop sounds in only one sprite?

like this Make a sprite like sound stopper
and you can pick and you can pick any event block

stop all sounds
GABOCSB18
Scratcher
28 posts

How do i stop sounds in only one sprite?

@bake121 I don't think that's what @riffsix wants. You should read his question more carefully.
AarnaFun
Scratcher
1 post

How do i stop sounds in only one sprite?

Hi i want two sprites to use same buttons to play different sounds. so i want to code that when the sprite is hidden it doesnt make any sounds what can i do?
thanks,aarnafun
orangeicecream23
Scratcher
100+ posts

How do i stop sounds in only one sprite?

Play a blank sound. Mockup:
SakuraPlaysYT
Scratcher
2 posts

How do i stop sounds in only one sprite?

I want to make it so one of my sprites plays a sound while another doesn't. Is there any way I can do this?
codingking465
Scratcher
1 post

How do i stop sounds in only one sprite?

Nice man really helped me @GABOCSB18

Last edited by codingking465 (March 12, 2023 17:47:58)

Powered by DjangoBB