FlxSlider
| Kind | class |
| Package | flixel.addons.ui |
| Full name | flixel.addons.ui.FlxSlider |
| Source | source/source-haxelib-patches/flixel/addons/ui/FlxSlider.hx |
| Extends | FlxSpriteGroup |
| Compiled when | #if FLX_MOUSE |
A slider GUI element for float and integer manipulation. @author Gama11
Public fields
| Name | Type | Static | Default | Notes |
|---|---|---|---|---|
body | FlxSprite | no | — | #if FLX_MOUSE · The horizontal line in the background. |
handle | FlxSprite | no | — | #if FLX_MOUSE · The dragable handle - loadGraphic() to change its graphic. |
minLabel | FlxText | no | — | #if FLX_MOUSE · The text under the left border - equals minValue by default. |
maxLabel | FlxText | no | — | #if FLX_MOUSE · The text under the right border - equals maxValue by default. |
nameLabel | FlxText | no | — | #if FLX_MOUSE · A text above the slider that displays its name. |
valueLabel | FlxText | no | — | #if FLX_MOUSE · A text under the slider that displays the current value. |
value | Float | no | — | #if FLX_MOUSE · Stores the current value of the variable - updated each frame. |
minValue | Float | no | — | #if FLX_MOUSE · Mininum value the variable can be changed to. |
maxValue | Float | no | — | #if FLX_MOUSE · Maximum value the variable can be changed to. |
decimals | Int | no | 0 | #if FLX_MOUSE · How many decimals the variable can have at max. Default is zero, or "only whole numbers". |
clickSound | String | no | — | #if FLX_MOUSE · Sound that's played whenever the slider is clicked. |
hoverSound | String | no | — | #if FLX_MOUSE · Sound that's played whenever the slider is hovered over. |
hoverAlpha | Float | no | 0.5 | #if FLX_MOUSE · The alpha value the slider uses when it's hovered over. 1 to turn the effect off. |
callback | Float->Void = null | no | — | #if FLX_MOUSE · A function to be called when the slider was used. The current relativePos is passed as an argument. |
setVariable | Bool | no | true | #if FLX_MOUSE · Whether the slider sets the variable it tracks. Can be useful to deactivate this in conjunction with callbacks. |
expectedPos | Float | no | — | property (get, never) · #if FLX_MOUSE · The expected position of the handle based on the current variable value. |
relativePos | Float | no | — | property (get, never) · #if FLX_MOUSE · The position of the handle relative to the slider / max value. |
varString | String | no | — | property (default, set) · #if FLX_MOUSE · Stores the variable the slider controls. |
Public methods
new (constructor)
function new(Object:Dynamic, VarString:String, X:Float = 0, Y:Float = 0, MinValue:Float = 0, MaxValue:Float = 10, Width:Int = 100, Height:Int = 15, Thickness:Int = 3, Color:Int = 0xFF000000, HandleColor:Int = 0xFF828282)
Only compiled when #if FLX_MOUSE.
Creates a new FlxSlider.
@param Object Reference to the parent object of the variable @param VarString Variable that the slider controls @param X x Position @param Y y Position @param MinValue Mininum value the variable can be changed to @param MaxValue Maximum value the variable can be changed to @param Width Width of the slider @param Height Height of the slider @param Thickness Thickness of the slider @param Color Color of the slider background and all texts except for valueText showing the current value @param HandleColor Color of the slider handle and the valueText showing the current value
| Parameter | Type | Default |
|---|---|---|
Object | Dynamic | — |
VarString | String | — |
X (optional) | Float | 0 |
Y (optional) | Float | 0 |
MinValue (optional) | Float | 0 |
MaxValue (optional) | Float | 10 |
Width (optional) | Int | 100 |
Height (optional) | Int | 15 |
Thickness (optional) | Int | 3 |
Color (optional) | Int | 0xFF000000 |
HandleColor (optional) | Int | 0xFF828282 |
update
override function update(elapsed:Float):Void
Only compiled when #if FLX_MOUSE.
| Parameter | Type | Default |
|---|---|---|
elapsed | Float | — |
setTexts
function setTexts(Name:String, Value:Bool = true, ?Min:String, ?Max:String, Size:Int = 8):Void
Only compiled when #if FLX_MOUSE.
Handy function for changing the textfields.
@param Name Text of nameLabel - null to hide @param Value Whether to show the valueText or not @param Min Text of minLabel - null to hide @param Max Text of maxLabel - null to hide @param Size Size to use for the texts
| Parameter | Type | Default |
|---|---|---|
Name | String | — |
Value (optional) | Bool | true |
Min (optional) | String | — |
Max (optional) | String | — |
Size (optional) | Int | 8 |
destroy
override function destroy():Void
Only compiled when #if FLX_MOUSE.
Cleaning up memory.
Internals
Private / internal members
| Field | Type | Static |
|---|---|---|
_bounds | FlxRect | no |
_width | Int | no |
_height | Int | no |
_thickness | Int | no |
_color | FlxColor | no |
_handleColor | FlxColor | no |
_object | Dynamic | no |
_lastPos | Float | no |
_justClicked | Bool | no |
_justHovered | Bool | no |
| Method |
|---|
function createSlider():Void |
function mouseInRect(rect:flixel.math.FlxRect) |
function updateValue():Void |
function get_expectedPos():Float |
function get_relativePos():Float |
function set_varString(Value:String):String |
override function set_x(value:Float):Float |
override function set_y(value:Float):Float |
inline function updateBounds() |