Skip to main content

FlxSlider

Kindclass
Packageflixel.addons.ui
Full nameflixel.addons.ui.FlxSlider
Sourcesource/source-haxelib-patches/flixel/addons/ui/FlxSlider.hx
ExtendsFlxSpriteGroup
Compiled when#if FLX_MOUSE

A slider GUI element for float and integer manipulation. @author Gama11

Public fields​

NameTypeStaticDefaultNotes
bodyFlxSpriteno—#if FLX_MOUSE · The horizontal line in the background.
handleFlxSpriteno—#if FLX_MOUSE · The dragable handle - loadGraphic() to change its graphic.
minLabelFlxTextno—#if FLX_MOUSE · The text under the left border - equals minValue by default.
maxLabelFlxTextno—#if FLX_MOUSE · The text under the right border - equals maxValue by default.
nameLabelFlxTextno—#if FLX_MOUSE · A text above the slider that displays its name.
valueLabelFlxTextno—#if FLX_MOUSE · A text under the slider that displays the current value.
valueFloatno—#if FLX_MOUSE · Stores the current value of the variable - updated each frame.
minValueFloatno—#if FLX_MOUSE · Mininum value the variable can be changed to.
maxValueFloatno—#if FLX_MOUSE · Maximum value the variable can be changed to.
decimalsIntno0#if FLX_MOUSE · How many decimals the variable can have at max. Default is zero, or "only whole numbers".
clickSoundStringno—#if FLX_MOUSE · Sound that's played whenever the slider is clicked.
hoverSoundStringno—#if FLX_MOUSE · Sound that's played whenever the slider is hovered over.
hoverAlphaFloatno0.5#if FLX_MOUSE · The alpha value the slider uses when it's hovered over. 1 to turn the effect off.
callbackFloat->Void = nullno—#if FLX_MOUSE · A function to be called when the slider was used. The current relativePos is passed as an argument.
setVariableBoolnotrue#if FLX_MOUSE · Whether the slider sets the variable it tracks. Can be useful to deactivate this in conjunction with callbacks.
expectedPosFloatno—property (get, never) · #if FLX_MOUSE · The expected position of the handle based on the current variable value.
relativePosFloatno—property (get, never) · #if FLX_MOUSE · The position of the handle relative to the slider / max value.
varStringStringno—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

ParameterTypeDefault
ObjectDynamic—
VarStringString—
X (optional)Float0
Y (optional)Float0
MinValue (optional)Float0
MaxValue (optional)Float10
Width (optional)Int100
Height (optional)Int15
Thickness (optional)Int3
Color (optional)Int0xFF000000
HandleColor (optional)Int0xFF828282

View source

update​

override function update(elapsed:Float):Void

Only compiled when #if FLX_MOUSE.

ParameterTypeDefault
elapsedFloat—

View source

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

ParameterTypeDefault
NameString—
Value (optional)Booltrue
Min (optional)String—
Max (optional)String—
Size (optional)Int8

View source

destroy​

override function destroy():Void

Only compiled when #if FLX_MOUSE.

Cleaning up memory.

View source

Internals​

Private / internal members
FieldTypeStatic
_boundsFlxRectno
_widthIntno
_heightIntno
_thicknessIntno
_colorFlxColorno
_handleColorFlxColorno
_objectDynamicno
_lastPosFloatno
_justClickedBoolno
_justHoveredBoolno
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()