Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » stopping a music loop and replacing it with another song
- stickyton3000
- Scratcher
3 posts
stopping a music loop and replacing it with another song
I'm trying to make an RPG game. When it's time for a battle, battle music plays. I have a variable named “music”, and at the beginning of a battle, the variable switches to 1 (meaning it plays sound number 1). Since sound number 1 is longer than the length of a battle, I want it to immediately switch to another track after the battle. But whenever I try to switch tracks, the first track always has to end first. Help is very much appreciated .
This is what I have so far:
This is what I have so far:
when green flag clicked
forever
if <[music] = [0]> then
stop all sounds
else
play sound [ musicv] until done
end
end
- -Tetro-
- Scratcher
100+ posts
stopping a music loop and replacing it with another song
I think using a message to play the battle music might work batter, like this:
when green flag clicked
forever
if <(music) = [0]> then
stop all sounds
else
broadcast [ battle music]
end
end
when I receive [ battle music]
play sound [ battle music] until done
Last edited by -Tetro- (March 20, 2019 01:26:19)
This is Thanos Cat. He snapped his fingers and destroyed half of Scratch. https://scratch.mit.edu/studios/5811684/
- stickyton3000
- Scratcher
3 posts
stopping a music loop and replacing it with another song
Thank you ! But sadly it didn't work
- Markadia07
- Scratcher
3 posts
stopping a music loop and replacing it with another song
when green flag clicked
forever
if <(Area) = [Farm]> then
stop all sounds
play sound [farm music] until done
end
end
when green flag clicked
forever
if <(Area) = [Arena]> then
stop all sounds
play sound [Arena Music] until done
end
end
This is what I used For My Game, It works, i tested it, reply if it doesn't work
Last edited by Markadia07 (March 20, 2019 02:29:34)
- deck26
- Scratcher
1000+ posts
stopping a music loop and replacing it with another song
Simpler, in my opinion, to do
when I receive [soundplayer v]
forever
play sound [music] until done
end
set [music v] to [1] // when battle is starting
broadcast [soundplayer v]
wait until <> // whatever tells you battle is over
set [music v] to [2]
stop all sounds
- stickyton3000
- Scratcher
3 posts
stopping a music loop and replacing it with another song
Thank you, everyone! I found the solution!
- Discussion Forums
- » Help with Scripts
- » stopping a music loop and replacing it with another song