Discuss Scratch

The_Red_Scratcher
Scratcher
10 posts

how do i make a music change smoothly using a slider variable?

so im trying to make a jukebox thing on my game and i want to smoothly transition between songs using a slider variable as well as a random song chooser when a song ends or the green flag is clicked is that too much too ask? idk but if anyone can help i'll apreciate it
The_Red_Scratcher
Scratcher
10 posts

how do i make a music change smoothly using a slider variable?

“im stupid” - The_Red_Scratcher

Last edited by The_Red_Scratcher (July 24, 2022 16:20:46)

scratch___user12345
Scratcher
1000+ posts

how do i make a music change smoothly using a slider variable?

do something like this to select a random song (this example is what you would do for two songs):
if <(pick random (1) to (2)) = [1]> then 
play sound [song one v]
else
play sound [song two v]
end
then do this if you want to have 3 songs, and so on:
if <(pick random (1) to (3)) = [1]> then 
play sound [song one v]
else
if <(pick random (1) to (3)) = [1]> then
play sound [song two v]
else
play sound [song three v]
end
end
The_Red_Scratcher
Scratcher
10 posts

how do i make a music change smoothly using a slider variable?

thank you @scratch__user12345! but it does not involve any variables… il try though

Last edited by The_Red_Scratcher (July 24, 2022 17:06:55)

scratch___user12345
Scratcher
1000+ posts

how do i make a music change smoothly using a slider variable?

The_Red_Scratcher wrote:

thank you @scratch__user12345! but it does not involve any variables… il try though
I don't get what you want the slider variable for. Is it so the user can choose the song?
The_Red_Scratcher
Scratcher
10 posts

how do i make a music change smoothly using a slider variable?

yes! it's so the user can change the song on the fly
cIoudyness
Scratcher
500+ posts

how do i make a music change smoothly using a slider variable?

here’s some scripts that might help:
when green flag clicked
show
set [ghost v] effect to (100)
set volume to (100)
set [slider variable v] to (1)
set [id v] to [follow pls]
broadcast [music v]

when I receive [music v]
if <(id) = [follow pls]> then
set [id v] to (slider variable) // this variable “for this sprite only”
create clone of [myself v]
set [id v] to [follow pls]
else
fade (-10)
delete this clone
end

when I start as a clone
fade (10)
wait until <not<(slider variable) = (id)>>
broadcast [music v]

when I start as a clone
repeat until <not<(slider variable) = (id)>>
play sound (slider variable) until done // make sure to name your sounds numbers that the slider can be.
end

define fade (increment)
if <(increment) = (10)> then
set volume to (0)
end
repeat (10)
change volume by (increment)
end
have tested something similar in a project but have changed it a tiny bit. if this doesn’t work i guess please do tell

Last edited by cIoudyness (July 24, 2022 20:06:26)

The_Red_Scratcher
Scratcher
10 posts

how do i make a music change smoothly using a slider variable?

thanks @cloudyness ill try it
The_Red_Scratcher
Scratcher
10 posts

how do i make a music change smoothly using a slider variable?

nevermind

Last edited by The_Red_Scratcher (July 24, 2022 20:35:46)

Powered by DjangoBB