Discuss Scratch

janinemelrose666
New Scratcher
6 posts

Looping sound until ...

Howdy
I'm new to this but am making a program that runs 2 games, a dress up game and a chase game. I have a home screen with buttons that allow the user to select which game to play and both games direct the user back to the home page after completion. In each game and on the home background I have different songs playing but haven't yet figured out how to loop them until directed to the different backgrounds. I'm currently playing the music through the background which i feel may be a part of the problem. I am stuck thinking “loop until… ” but don't know what to put in the blank space. My brain keeps going back to receiving messages but that doesn't line up… please help!
GoldenKat
Scratcher
28 posts

Looping sound until ...

when green flag clicked
set [ stop] to [0]
forever
if <[stop] = [stop music]> then


stop all sounds

else
play sound [ music] until done
end
end

when backdrop switches to [ other backdrop]
set [ stop] to [stop music]
janinemelrose666
New Scratcher
6 posts

Looping sound until ...

Yay you're the best! i'll give it a go
gor-dee
Scratcher
1000+ posts

Looping sound until ...

GoldenKat wrote:

when green flag clicked
set [ stop] to [0]
forever
if <[stop] = [stop music]> then


stop all sounds

else
play sound [ music] until done
end
end

when backdrop switches to [ other backdrop]
set [ stop] to [stop music]
That won't stop the music until the end of the song because the script will be waiting for the music to end before it loops. If you are using the backdrops to detect when to change the music you could have
when backdrop switches to [ backdrop 1 v]
stop all sounds
repeat until <not <(backdrop #) = [1]>>
play sound [music 1 v] until done
end

and
when backdrop switches to [ backdrop 2  v]
stop all sounds
repeat until <not <(backdrop #) = [2]>>
play sound [music 2 v] until done
end
and so on

Last edited by gor-dee (May 10, 2018 00:53:58)

janinemelrose666
New Scratcher
6 posts

Looping sound until ...

Thank you! Got it running
GoldenKat
Scratcher
28 posts

Looping sound until ...

yay!

Powered by DjangoBB