Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: CoffeeBob on Fri 01/07/2005 23:07:34

Title: N00b-coder wanted to know how to make basic slider-code. (SOLVED)
Post by: CoffeeBob on Fri 01/07/2005 23:07:34
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
Title: Re: N00b-coder wants to know how to make basic slider-code.
Post by: Candle on Fri 01/07/2005 23:53:45
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 .
Title: Re: N00b-coder wants to know how to make basic slider-code.
Post by: monkey0506 on Sat 02/07/2005 03:22:58
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.
Title: Re: N00b-coder wants to know how to make basic slider-code.
Post by: CoffeeBob on Sat 02/07/2005 12:11:48
Ok, thanks guys. Problem solved. ;D
Title: Re: N00b-coder wanted to know how to make basic slider-code. (SOLVED)
Post by: monkey0506 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?
Title: Re: N00b-coder wanted to know how to make basic slider-code. (SOLVED)
Post by: CoffeeBob on Sun 03/07/2005 00:24:36
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. :)