Skip to content
ClassUI & Typography@public

FlxBar

Deterministic value bar with renderer-owned fill geometry.

The optional parent/property binding is read once per fixed update. Rendering never regenerates textures when the value changes.

ts
export declare class FlxBar extends FlxSprite

Constructors

ts
constructor(x?: number, y?: number, direction?: FlxBarFillDirection, width?: number, height?: number, parent?: object | null, variable?: string, minimum?: number, maximum?: number, showBorder?: boolean)

Constructs a new instance of the FlxBar class

ParameterTypeDescription
xnumber-
ynumber-
directionFlxBarFillDirection-
widthnumber-
heightnumber-
parentobject | null-
variablestring-
minimumnumber-
maximumnumber-
showBorderboolean-

Properties

PropertyModifiersTypeDescription
barHeightreadonlynumberLogical bar height in pixels.
barWidthreadonlynumberLogical bar width in pixels.
borderColorreadonlynumberPacked 0xRRGGBBAA border color.
BOTTOM_TO_TOPstatic readonly``-
direction-FlxBarFillDirection-
emptyCallback-FlxBarCallback | null-
emptyColorreadonlynumberPacked 0xRRGGBBAA empty/background color.
fillColorreadonlynumberPacked 0xRRGGBBAA fill color.
filledCallback-FlxBarCallback | null-
fixedPosition-booleanWhen false, the bar follows its parent position each fixed update.
fractionreadonlynumberCurrent value normalized to the inclusive range, from 0 through 1.
HORIZONTAL_INSIDE_OUTstatic readonly``-
HORIZONTAL_OUTSIDE_INstatic readonly``-
killOnEmpty-boolean-
LEFT_TO_RIGHTstatic readonly``-
maximumreadonlynumber-
minimumreadonlynumber-
parentreadonlyobject | nullBound parent object, when value tracking is active.
parentVariablereadonlystringProperty name read from the bound parent object each fixed update.
percentreadonlynumberCurrent value as a percentage from 0 through 100.
positionOffsetreadonlyFlxPoint-
RIGHT_TO_LEFTstatic readonly``-
showBorderreadonlyboolean-
TOP_TO_BOTTOMstatic readonly``-
value-number-
VERTICAL_INSIDE_OUTstatic readonly``-
VERTICAL_OUTSIDE_INstatic readonly``-

Methods

createFilledBar()

ts
createFilledBar(emptyColor?: number, fillColor?: number, showBorder?: boolean, borderColor?: number): this

Parameters:

ParameterTypeDescription
emptyColornumber-
fillColornumber-
showBorderboolean-
borderColornumber-

Returns: this

createRenderHandle()

ts
createRenderHandle(): FlxBarRenderHandle

Returns: FlxBarRenderHandle

destroy()

ts
destroy(): void

Returns: void

setCallbacks()

ts
setCallbacks(emptyCallback?: FlxBarCallback | null, filledCallback?: FlxBarCallback | null, killOnEmpty?: boolean): this

Parameters:

ParameterTypeDescription
emptyCallbackFlxBarCallback | null-
filledCallbackFlxBarCallback | null-
killOnEmptyboolean-

Returns: this

setParent()

ts
setParent(parent: object | null, variable: string, track?: boolean, offsetX?: number, offsetY?: number): this

Bind a parent object and optional property for value tracking.

When track is true the bar also follows the parent position using offsetX and offsetY.

Parameters:

ParameterTypeDescription
parentobject | null-
variablestring-
trackboolean-
offsetXnumber-
offsetYnumber-

Returns: this

setRange()

ts
setRange(minimum: number, maximum: number): this

Parameters:

ParameterTypeDescription
minimumnumber-
maximumnumber-

Returns: this

setValueProvider()

ts
setValueProvider(provider: FlxBarValueProvider | null): this

Parameters:

ParameterTypeDescription
providerFlxBarValueProvider | null-

Returns: this

stopTrackingParent()

ts
stopTrackingParent(posX: number, posY: number): this

Stop following the parent and remain at the given world position.

Parameters:

ParameterTypeDescription
posXnumber-
posYnumber-

Returns: this

trackParent()

ts
trackParent(offsetX: number, offsetY: number): this

Bind a parent object property for value tracking, or follow an already-bound parent's position when the first argument is a numeric offset.

Parameters:

ParameterTypeDescription
offsetXnumber-
offsetYnumber-

Returns: this

trackParent()

ts
trackParent(parent: object | null, variable: string): this

Parameters:

ParameterTypeDescription
parentobject | null-
variablestring-

Returns: this

update()

ts
update(): void

Returns: void

Released under the MIT License.