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

#1 2012-06-05 12:42:10

Shinkaze
Scratcher
Registered: 2012-05-27
Posts: 44

How do I change music during the game?

Read the following, since the actual question is a bit more complex than the topic title
I am making a Kingdom Hearts game, and I need the music to change after each level.
I am currently using this sort of script:

when I receive [Level 1]
play sound [Level 1 Music] until done
and then
when I receive [Level 2]
stop all sounds 
play sound [Level 2 Music] until done
And so on. But with that, if the player spends ages on Level 1, the music would just end since I have not scripted it to loop. So I tried this:

when I receive [Level 1]
set [music] to [level 1]
and then
when gf clicked
repeat until < (music) = [Level 2] >
play sound [Level 1 Music] until done
end
But that doesn't work. I also tried substituting the 'play sound ___ until done' for just 'play sound ___' but that didn't work either.

How do I get this to work? Am I missing something simple?
SK


http://thisisagoodbook.com/images/shinkazesig2.png

Offline

 

#2 2012-06-05 13:01:45

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: How do I change music during the game?

Your second idea should work. Are you maybe missing a "set music to level 2" before the stop all sounds?

Offline

 

#3 2012-06-05 13:02:36

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: How do I change music during the game?

Here is a script I use for my personal music projects not online.

when [sprite 1 v] clicked
stop all sounds
set [music v] to [0]
forever
play sound [sound v] until done
if <not<(music) = [0]>>
stop script
end
For a level, just swap out the when sprite clicked for when I recieve. It works because the stop all sounds will stop the sound, and automatically go to the next part of the script, yours might even work if you use the stop sounds block. But the current script you have will play the music, regardless of variable change, until it's done, then check for change.

Last edited by sonicfan12p (2012-06-05 14:49:00)


Why are the secret organizations getting all the attention?  mad

Offline

 

#4 2012-06-05 14:46:03

Shinkaze
Scratcher
Registered: 2012-05-27
Posts: 44

Re: How do I change music during the game?

@sonicfan12p Yes that works! Thank you!

SK


http://thisisagoodbook.com/images/shinkazesig2.png

Offline

 

#5 2012-06-05 14:48:46

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: How do I change music during the game?

Your Welcome!  big_smile


Why are the secret organizations getting all the attention?  mad

Offline

 

#6 2012-06-05 20:48:45

fetzer
Scratcher
Registered: 2009-06-11
Posts: 70

Re: How do I change music during the game?

Eh, i was thinking along the lines of something else, but its ok...

Offline

 

Board footer