Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Volume Slider
- Unicornnnss
-
Scratcher
8 posts
Volume Slider
Hello! I need to learn how to make a music & audio slider. I want them to be separate, and also have a simple code. I don't want it to be a variable slider, since I want it to be customizable. Thank you to anyone who replies 
~ Unicornnnss

~ Unicornnnss
Last edited by Unicornnnss (Nov. 19, 2017 02:52:34)
- awesome-llama
-
Scratcher
1000+ posts
Volume Slider
Each sprite has their own, individual volume setting. If you have music in one sprite and other audio in another, it is possible to change the volume in one without affecting the other.
- ShadowEXE492
-
Scratcher
3 posts
Volume Slider
Doing this with the variable slider is very easy and changing the volume can be done with a simple code block:
making sure that the variable slider is set from 0 to 100. However creating a custom slider is more difficult which requires 4 if statements. I have created a sample project to demostrate how this can be done. https://scratch.mit.edu/projects/187473947/#player
set volume to (Vol) %
making sure that the variable slider is set from 0 to 100. However creating a custom slider is more difficult which requires 4 if statements. I have created a sample project to demostrate how this can be done. https://scratch.mit.edu/projects/187473947/#player
- _Circuit-
-
Scratcher
82 posts
Volume Slider
Normally, I would use 2 sprites, one as the bar and the other as the button you drag.
I don't entirely remember how to do this, but the draggable button sprite would set a variable to the x position divided by or multiplied by something.
Then, a script like
I hope this helps.
btw, there are many projects with volume bar physics which the creator allows you to use with credit
I don't entirely remember how to do this, but the draggable button sprite would set a variable to the x position divided by or multiplied by something.
Then, a script like
when green flag clickedin every sprite in which its volume you want to be variable.
forever
set volume to (vol) %
end
I hope this helps.
btw, there are many projects with volume bar physics which the creator allows you to use with credit
- Unicornnnss
-
Scratcher
8 posts
Volume Slider
Okay, this is what I have so far for one of the buttons:
~ Unicornnnss
if <<touching [mouse pointer v]> and <mouse down>> thenWhat the problem is, is I can't stop it from going outside of the bar. I guess I sort of need a barrier, does anyone know how I can do this? Thank you!
repeat until <not <mouse down>>
go to x: (mouse x) y: (61)
~ Unicornnnss
- Unicornnnss
-
Scratcher
8 posts
Volume Slider
Each sprite has their own, individual volume setting. If you have music in one sprite and other audio in another, it is possible to change the volume in one without affecting the other.Can I also do this with clones?
- Unicornnnss
-
Scratcher
8 posts
Volume Slider
Okay, this is what I have so far for one of the buttons:Figured it out. All I need to do now is connect the volume to the sliders.if <<touching [mouse pointer v]> and <mouse down>> thenWhat the problem is, is I can't stop it from going outside of the bar. I guess I sort of need a barrier, does anyone know how I can do this? Thank you!
repeat until <not <mouse down>>
go to x: (mouse x) y: (61)
~ Unicornnnss
- Discussion Forums
- » Help with Scripts
-
» Volume Slider