Page 1 of 1

Volume

PostPosted: Thu Feb 14, 2008 9:03 am
by summer_goth
Hi there,

In the settings I've got it so that one can set the volume louder and softer.

However it just never seems to set the volume to 0. I know I'm doing something wrong, but I'm not sure what.

This is the code for a mouse up click event:

Code: Select all
if (musicvol != 0)
{
  musicvol -= 0.2;
}


The volume starts at 1. So eventually it should get to 0, but it doesn't. Is musicvol being rounded down maybe? Eh, I don't know.

Thanks for the help.

Re: Volume

PostPosted: Thu Feb 14, 2008 10:12 am
by Bee-Ant
Yeah...making musicvol=0; wont make your music to be silent...btw,if you dont wanna use music...why dont you just set your speaker volume?Oh...so,you wanna make something like volume effect?

Re: Volume

PostPosted: Thu Feb 14, 2008 4:19 pm
by summer_goth
Nope, as far as I can see setting musicvol to zero will make it mute. However with the code I showed it doesn't seem to reach zero.

I can't just set my speaker volume. It's a game that's going to be released for Windows Mobile devices. It has settings and one of those settings is to set the volume. If I played a game on Windows Mobile and it didn't give me options to set the volume I would be rather irritated.

Does anyone know what I'm doing wrong?

Thanks for the help.

Re: Volume

PostPosted: Thu Feb 14, 2008 4:30 pm
by Bee-Ant
yeah...changing musicvol to 0 doesnt make your music to be silent

Re: Volume

PostPosted: Thu Feb 14, 2008 7:45 pm
by makslane
summer_goth wrote:In the settings I've got it so that one can set the volume louder and softer.
However it just never seems to set the volume to 0.


It's a precision problem of the script engine.
Put this code after yours:

Code: Select all
if(musicvol < 0.0) musicvol = 0.0;

Re: Volume

PostPosted: Thu Feb 14, 2008 7:48 pm
by summer_goth
Thank you very much Makslane.

Re: Volume

PostPosted: Fri Feb 15, 2008 11:37 am
by Bee-Ant
What is the difference between 0 and 0.0 anyway??? :lol: :lol: :lol:

Re: Volume

PostPosted: Fri Feb 15, 2008 6:26 pm
by makslane
0 is a integer, 0.0 is a float.
To not make errors when the formula have a float variable, like musicvol, I like to use float numbers.

Re: Volume

PostPosted: Fri Feb 15, 2008 6:53 pm
by edh
@B-A: The difference is the precision! :lol:

Re: Volume

PostPosted: Sat Feb 16, 2008 1:56 am
by Bee-Ant
:wink: :lol:

Re: Volume

PostPosted: Sat Feb 16, 2008 6:19 am
by Game A Gogo
this needs to be quoted... seriously, sounds epic!

Re: Volume

PostPosted: Sun Feb 17, 2008 3:46 am
by Bee-Ant
:roll: