Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Stopping one sound and starting another
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
So im trying to make a game in which when it starts the game it plays some music forever until it switches to a specific background. So like when it switches to the boss background it stops the music and plays a different sound, how can i do this?
- LoudOrange2001
-
Scratcher
48 posts
Stopping one sound and starting another
after the block where it says change backdrop to…..
put play sound….. forever.
hope this helps
LoudOrange
put play sound….. forever.
hope this helps
LoudOrange
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
but with doing that the previous sound is still playing
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
Bump
i really need this answered
i really need this answered
- PH-zero
-
Scratcher
100+ posts
Stopping one sound and starting another
just dont use a forever block, do it like this:
This should work
set [repeat v] to [true]
repeat until <(repeat) = [false]>
play sound [myMusic v] until done
end
switch backdrop to [someBackdrop v]
set [bool v] to [false]
stop all sounds
This should work

Last edited by PH-zero (June 7, 2014 15:21:44)
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
shouldnt bool be repeat instead otherwise thanks so much
- mathman314
-
Scratcher
100+ posts
Stopping one sound and starting another
Here's another alternative:

repeat until <(backdrop name) = [boss backdrop]>Use this to make yourself look smart!
play sound [that sound v]
reset timer
repeat until <(timer) = (length of that sound)>
if <(backdrop name) = [boss backdrop]> then
stop all sounds
play sound [boss music v]
stop [this script v]
end
end
end

Last edited by mathman314 (June 8, 2014 13:23:39)
- juicykiwi
-
Scratcher
86 posts
Stopping one sound and starting another
when green flag clicked
repeat until <<[<[(b(backdrop name)= [boss]>
p
play sound [before boss v] until done
end
playcratchblocks]
play sound [ after bossv] until done
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
thanks alot for all your help guys
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
Mathman i tried you way and i doesnt seem to be changing, i put the time in seconds (ex: a 2 minute and 11 second long song is 131) and dont know if that is messing up or i put the code in the wrong place ( i put it in my main sprite) please help 

- RPFluffy
-
Scratcher
1000+ posts
Stopping one sound and starting another
Try this, it is quite easy and a great way to getting into more complex things:
repeat until <(backdrop name) = [Backdropname]>
play sound [Music v] until done
end
play sound [OtherMusic v] until done
- plopdop1
-
Scratcher
6 posts
Stopping one sound and starting another
you could just use the play sound that doesn't say until finished and then wait however long you want it to be
when green flag clicked
play sound [ v]
wait (...) secs
Last edited by plopdop1 (June 9, 2014 01:01:24)
- Burrito997
-
New Scratcher
14 posts
Stopping one sound and starting another
the problem with the scripts you are giving me is that when i get to the boss and the background changes and the main music is still playing it keeps playing until done. Then it starts the boss music, i want it to fade out and then the boss music to start instantly.
- digthebone
-
Scratcher
500+ posts
Stopping one sound and starting another
when green flag clicked
play sound [radom song v]
wait (as much seconds as you want) secs
stop all sounds
play sound [another random song v]
hopefully that helped

and always remember
when green flag clicked
forever
if <got help from digthebone> then
know he is awesome
end
end
digthebone's logo shop
- Leonitis
-
Scratcher
11 posts
Stopping one sound and starting another
Here is the best and most effective way to do it! It is also very simple! Here it is:
when backdrop switches to [ v]
forever
if <(backdrop name) = [ ]> then
play sound [ v] until done
end
end
- Leonitis
-
Scratcher
11 posts
Stopping one sound and starting another
Sorry! Put
Instead of
repeat until <>
end
Instead of
if <> then
end
- MinecraftButterfly
-
Scratcher
7 posts
Stopping one sound and starting another
You Can Do THIS:
When Flag Clicked
Set {VARIABLE} To 0
Repeat Until {VARIABLE = 1
Play Sound {ANY} Until Done
When This Sprite Clicked
Broadcast {MESSAGE}
When I Recive {MESSAGE}
Set {VARIABLE} to 1
Forever
Play Sound {ANY} Until Done
THIS Is probably the most effective way!
When Flag Clicked
Set {VARIABLE} To 0
Repeat Until {VARIABLE = 1
Play Sound {ANY} Until Done
When This Sprite Clicked
Broadcast {MESSAGE}
When I Recive {MESSAGE}
Set {VARIABLE} to 1
Forever
Play Sound {ANY} Until Done
THIS Is probably the most effective way!
Last edited by MinecraftButterfly (May 11, 2016 11:27:35)
- Discussion Forums
- » Help with Scripts
-
» Stopping one sound and starting another









