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

#1 2009-11-08 08:26:18

fullwall
Scratcher
Registered: 2009-10-29
Posts: 20

Help with music changes...

Well, as my topic says, I can't get the music to change on my game. Right now, I have a screen variable which changes when you hit the edge. I want the music to change when the variable is at a certain number. However, to get the music to loop, I have had to put is as a play until done loop. This means that the script doesn't check for the screen changes until the 2 minute song finishes, or until I manually restart the loop, in which case it does check. Can somebody offer me a suggestion? The code is on my Hero sprite if you want to look at it here: http://scratch.mit.edu/projects/fullwall/750506

Last edited by fullwall (2009-11-08 08:28:08)

Offline

 

#2 2009-11-08 10:58:54

waterbuddy16
Scratcher
Registered: 2009-08-18
Posts: 25

Re: Help with music changes...

you want it so if you touch a wall a music loops right?


http://img21.imageshack.us/img21/9258/awesomepu.gif The pentagon approves of my awesomeness. It doeshttp://dragcave.net/image/u9Sn.gifhttp://dragcave.net/image/mHJD.gif

Offline

 

#3 2009-11-08 11:09:23

BWOG
Scratcher
Registered: 2008-09-19
Posts: 1000+

Re: Help with music changes...

if <(variable) = (1) >
Play sound [music1] until done
end if

Last edited by BWOG (2009-11-08 11:09:39)

Offline

 

#4 2009-11-08 18:45:26

fullwall
Scratcher
Registered: 2009-10-29
Posts: 20

Re: Help with music changes...

But where is the end if block? As I said, if I just put a stop script inside an if block, it just doesn't check if it's true.

Offline

 

#5 2009-11-09 04:06:58

fullwall
Scratcher
Registered: 2009-10-29
Posts: 20

Re: Help with music changes...

Bump. Basically what I need is a script that loops music until the variable is a certain value, in which case it changes to a different song. As I said earlier, if I just put a stop script inside an if block, it doesn't check if it's true.

Offline

 

#6 2009-11-09 04:40:57

Ralphjos
Scratcher
Registered: 2009-10-10
Posts: 100+

Re: Help with music changes...

Code:

<Forever>
   <if Variable = 1>
      Play sound
      Wait until Not Variable = 1
      Stop all Sound
   End If
   <if Variable = 2>
      Play diff. Sound
      Wait until Not Variable = 2 
      Stop all sound
   End if
End forever

Do this as much times for each diff. peice of music needed. If it doesnt work, tell me.

    Regards,
       Ralphj
os

Edit: The <end if> isnt a block, its the little thing after the if is finished, this goes for all of the Ends:

<end>

Last edited by Ralphjos (2009-11-09 04:41:58)


http://i33.tinypic.com/2dt3j9j.gif

Offline

 

#7 2009-11-09 05:15:51

deatheater
Scratcher
Registered: 2008-04-11
Posts: 1000+

Re: Help with music changes...

two scripts

<when green flag clicked>
<forever>
<if><( <{ variable }> <=> 1 )>
<stop all sounds>
<play sound[ sound1 ]and waits>
<end>
<end>
[/blocks]

and


<when green flag clicked>
<forever>
<if><( <{ variable }> <=> 2 )>
<stop all sounds>
<play sound[ sound2 ]and waits>
<end>
<end>

[/blocks] Put both those scripts on the same sprite  smile

Offline

 

Board footer