Game Development Community

Locking Slider Controls

by David Taylor · in Torque Game Builder · 09/04/2006 (6:52 pm) · 2 replies

I'm not sure if 'locking' was necessarily the correct term, but here is what I want to be able to to do.

I have a GuiSliderCtrl called PlayerStrength. When I slide the bar left and right, it assigns the value of the slider, (between 1 and 10), to the player's strength. Simple, right?

But what I want to do is have the only available options for numerical choices being whole numbers. (That is, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10.) Presently, it will take anything, such as 3.0882 and 6.3235. I'd like the slider to have 'notches' where the only valid options are...so dragging the scroller would mean it would fall into one of these fixed positions, as opposed to finding any position along the line.

Does anyone understand what I'm trying to get at? It's surprisingly difficult to explain.

#1
09/04/2006 (7:14 pm)
Slider bars are tick-able; with the number of ticks set in the GUI control code. Set "ticks = "10";" If you want 10 divisions in the slider. To get the bar to only recognize the tick marks (and nothing in between), hold down the shift key. I have no idea how to set it up to have ticks-only be the default behavior; without the modifier key. I wish I did; since it would be really handy for things!
#2
09/07/2006 (10:14 pm)
Thanks, Don. That did the trick, albeit not by default. I've decided to try using clusters of radio buttons instead, because I prefer the look, but that has brought it's own problems, lol.

http://www.garagegames.com/mg/forums/result.thread.php?qt=50418