Hello there!
I'm having problems with sliders in my game. Since I'm no coding genius (I only know the very easy stuff), I can't get the sliders to work properly.
So could anyone provide me with a basic code that tells how to make a slider alter the sound-volume?
Thanks in advance,
Largo
If you look in the demo ( don't seem to be on the download page) there are sliders in it .
If you can't find the demo let me know and I'll try to upload it .
It depends on what version of AGS.
2.62:
/* on_key_press */
if (keycode == 372) /* up arrow */
SetSliderValue(GUI, SLIDER, GetSliderValue(GUI, SLIDER) + 1);
else if (keycode == 380) /* down arrow */
SetSliderValue(GUI, SLIDER, GetSliderValue(GUI, SLIDER) - 1);
/* rep_ex */
SetMusicMasterVolume(GetSliderValue(GUI, SLIDER));
You'll probably want to change the keycodes, the GUI name, the SLIDER name, and the "+/- 1" to something like "+/- 9" (because changing the music level by 1 doesn't make much difference). And you'll have to double check parameter lists.
If you're using version 2.7:
/* on_key_press */
if (keycode == 372) /* up arrow */
Slidername.Value++;
else if (keycode == 380) /* down arrow */
Slidername.Value--;
/* rep_ex */
SetMusicMasterVolume(Slidername.Value);
Once again, you'll probably want to change the keycodes, change the name of Slidername, and change ++/-- to something like +9/-9 (because as previously noted chaning the music level by 1 doesn't make much (audible) difference).
I hope you can understand and make use of what I wrote here.
Ok, thanks guys. Problem solved. ;D
Oops. Glad to hear you got it working, but I just noticed a problem. Under the 2.7 code I wrote to change ++/-- to +9/-9, but it should be +=/-= 9. BTW, what version of AGS are you using?
Quote from: monkey_05_06 on Sat 02/07/2005 21:41:47
Oops.Ã, Glad to hear you got it working, but I just noticed a problem.Ã, Under the 2.7 code I wrote to change ++/-- to +9/-9, but it should be +=/-= 9.Ã, BTW, what version of AGS are you using?
I'm using 2.7. I got the code working in a simpler way, but your code helped me getting it together as well. :)