This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-06-24 11:09:54

comsciman
New Scratcher
Registered: 2012-05-20
Posts: 6

Play Continuous Sound Loop and then Stop

I have a game in which I want a continuous music loop, say HipHop, to repeat and keep playing until near the end of the game. In the Stage or Sprite script I build a Forever Loop around Play Sound HipHop Until Done. That works. However, at the end of game I want that sound loop to quit so I can play another sound, say a meow. I tried putting in Stop all Sounds in my script but that doesn't stop the HipHop. Seems Stop all Sounds doesn't Stop all Sounds in all scripts including the stage. Suggestions/insight? Thanks

Offline

 

#2 2012-06-24 11:20:51

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Play Continuous Sound Loop and then Stop

You'll need to use a variable.

Insert this script:

when gf clicked
set [play v] to [1]
forever
 if <(play) = [1]>
  play sound [HipHop v] until done
 end
end
Now, to stop it, and play Meow, use this script:

set [play v] to [0]
stop all sounds
play sound [Meow v]
Or, if you want it to LOOP meow, do this:

when gf clicked
set [play v] to [1]
forever
 if <(play) = [1]>
  play sound [HipHop v] until done
 else
  play sound [Meow v] until done
 end
end
To switch:

set [play v] to [0]
stop all sounds
I hope you get the picture...

Last edited by SciTecCf (2012-06-24 11:24:51)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#3 2012-06-24 12:35:06

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Play Continuous Sound Loop and then Stop

SciTecCf wrote:

You'll need to use a variable.

...

To switch:

set [play v] to [0]
stop all sounds
I hope you get the picture...

Your last script is wrong (see the red block?). The correct one is:

set [play v] to [0]
stop all pinks
(Lol?)


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

#4 2012-06-24 12:48:04

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Play Continuous Sound Loop and then Stop

Molybdenum wrote:

SciTecCf wrote:

You'll need to use a variable.

...

To switch:

set [play v] to [0]
stop all sounds
I hope you get the picture...

Your last script is wrong (see the red block?). The correct one is:

set [play v] to [0]
stop all pinks
(Lol?)

lol  That is weird.


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#5 2012-06-24 21:03:20

comsciman
New Scratcher
Registered: 2012-05-20
Posts: 6

Re: Play Continuous Sound Loop and then Stop

Thanks SciTecCf. Your suggestion worked.

I don't understand Molybdenum's suggestion of after set play to 0 the "stop all pinks"
Where does one find the instruction "stop all pinks"?

Thanks to you both for your prompt replies.

Offline

 

#6 2012-06-24 21:29:31

Molybdenum
Scratcher
Registered: 2012-06-17
Posts: 1000+

Re: Play Continuous Sound Loop and then Stop


"The Enrichment Center is required to remind you that you will be baked, and then there will be cake."
(|Balls and Platforms: Stay on!|) (|NaOS-H: An operating system... Or is it?|)

Offline

 

Board footer