Pages: 1
Topic closed
Hi,
I've created a game... http://scratch.mit.edu/projects/SonicPopsDad/228307
The small problem I've got is that I'm looping techno music during the main game whilst the user is playing, but I've got no way of stopping it in mid-flow...
so basically I want to halt the game, but the music might need 8 seconds (the length of the sample) to continue before it can hand over to the next process.
is there anyway better to structure than this...?
until playing = 0
play techno until done
(repeat)
play end music
cheers!
Offline
keroro645 wrote:
Do you mean you want the music to stop playing when something happens.
yup, that's what I'd like.
I should explain 'playing' is a global variable I switch to 1 when the user is playing the game, and is set to '0' when he/she runs out of power, and 'game over' gets displayed.
If I do
until playing = 0
play techno
(repeat)
then it just plays the first note before starting again.
I wondered if I could do something like...
until playing = 0
play techno
count = 0
until playing = 0 and count = 1000 (or whatever number of repetitions I need)
change count by 1
(repeat)
if playing = 0
stop script
(repeat)
but I'm worried the repetition count might be influenced by how much I'm stressing the computer do all the rest of the stuff... so I might start chopping the music off half way through, or leaving gaps between plays
I can't try this now cos I'm at work
Last edited by SonicPopsDad (2008-07-30 12:23:51)
Offline
Use sensoring thats wat i do.Make a music variable.
<when green flag clicked>
<forever>
<if><( <{ music }> <=> 1 )>
<play sound[ techno]
<end>
<if><( <{ music }> <=> 2 )>
<play sound[ end]
<end>
<end>
Offline
Ahhhhh, I get the reason...
when I tried a loop with a 'play techno' it also had some other commands it'd process in the loop, and it was doing *those* that stopped the music playing and restarted it from the beginning (which caused it to just stutter on the first note)
so if I have a loop where the *only* thing it does is play the music, then it'll work
great - many thanks!
edit: actually it didn't seem to work, it still seemed happy to stop itself and start the sample from the beginning again.
So I reverted to 'play sound until done' but also made use of the 'stop playing sounds' block which does a good job of cutting the longer samples in mid-flow! So I'm much better off than I was
Last edited by SonicPopsDad (2008-07-30 21:47:36)
Offline
Topic closed
Pages: 1