Discuss Scratch

RUBIXS
New to Scratch
60 posts

Help with music!!!

Hey Scratchers!!!
I'm working on a game that has a soundtrack too it and i wanted to add a mute feature by pressing “m”
But its not working.
Hope you guys can help
Dundil
New to Scratch
11 posts

Help with music!!!

Just add a command set volume to 0% when “m” key is pressed.
dracae
Scratcher
1000+ posts

Help with music!!!

Try this:
When GreenFlag clicked
Set volume to 100%

When m key is pressed
Set volume to ((abs of ((volume / 100) - 1)) * 100) %

Abs means absolute value.
Plug in 100% and 0% to see how it works.

Hope I helped!

(EDIT: This switches the volume back and forth from 0% to 100%
If you don't want the player to be able to switch back to 100% again, use BobStanley's method)

Last edited by dracae (June 5, 2013 12:53:23)


BobStanley
Scratcher
100+ posts

Help with music!!!

When m key is pressed
Set volume to (0%)

Last edited by BobStanley (June 5, 2013 12:49:47)


dracae made this picture V | Like a Glover | Tau is awesome | dracae also made that GIF >, Flash 11.8 (release 800)
RUBIXS
New to Scratch
60 posts

Help with music!!!

dracae wrote:

Try this:
When GreenFlag clicked
Set volume to 100%

When m key is pressed
Set volume to ((abs of ((volume / 100) - 1)) * 100) %

Abs means absolute value.
Plug in 100% and 0% to see how it works.

Hope I helped!

(EDIT: This switches the volume back and forth from 0% to 100%
If you don't want the player to be able to switch back to 100% again, use BobStanley's method)


Where is the absolute value thing???
AronE
Scratcher
20 posts

Help with music!!!

operators!! (change sqrt to abs)
RUBIXS
New to Scratch
60 posts

Help with music!!!

Thank you so much guys!!!!
dracae
Scratcher
1000+ posts

Help with music!!!

Glad we could help!
Here's a picture to clarify:

ImagineIt
Scratcher
1000+ posts

Help with music!!!

dracae wrote:

Glad we could help!
Here's a picture to clarify:
It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.
dracae
Scratcher
1000+ posts

Help with music!!!

ImagineIt wrote:

It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.

Well, I try to avoid using too many variables, because it gets sort-of messy when you have a ton of variables…
Especially with the amount of variables I use in the first place! XD

RUBIXS
New to Scratch
60 posts

Help with music!!!

dracae wrote:

ImagineIt wrote:

It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.

Well, I try to avoid using too many variables, because it gets sort-of messy when you have a ton of variables…
Especially with the amount of variables I use in the first place! XD


Yeah… I already have 25+ variables
dracae
Scratcher
1000+ posts

Help with music!!!

RUBIXS wrote:

dracae wrote:

ImagineIt wrote:

It would probably be less complicated if there was a variable called “Muted?” and would be set to 0 if it was equal to 1, and the other way around. It would set the volume to 0 if the variable equaled 1, while it would do the opposite if it equaled zero.

Well, I try to avoid using too many variables, because it gets sort-of messy when you have a ton of variables…
Especially with the amount of variables I use in the first place! XD


Yeah… I already have 25+ variables

Of course we aren't saying variables are bad or anything!
Variables are the essence of a powerful project.

Powered by DjangoBB