Optional Flixel bridge (compiled only when the flixel haxelib is present).

Solves the three points of friction between SmiðrUI and a Flixel host:

  • Viewportinit() parents the UIRoot inside FlxG.game below the cursor container, so UI coordinates equal Flixel game coordinates under every scale mode with zero per-frame sync (Flixel's custom cursor also renders above the UI for free). init(false) stage-attaches instead and keeps setViewport synced on resize.
  • Cursor — with a custom FlxG.mouse cursor the system cursor is hidden, so widget hoverCursors never show; cursorMode = CURSOR_SYSTEM_OVER_UI restores the system cursor while the pointer is over UI, or assign onOverUIChanged to swap your own cursor art.
  • Input arbitrationmouseBlocked / keysBlocked are the two flags the game checks before processing its own input; autoBlockMouse = true toggles FlxG.mouse.enabled automatically instead.

World-space UI (nameplates, markers) goes through worldToUIX/Y or the anchor() list, which repins display objects to world points each postUpdate.

Static variables

@:value(false)staticautoBlockMouse:Bool = false

When true, FlxG.mouse.enabled is toggled off while the UI owns the pointer.

@:value(CURSOR_NONE)staticcursorMode:UICursorMode = CURSOR_NONE

One of CURSOR_NONE / CURSOR_SYSTEM_OVER_UI.

staticread onlykeysBlocked:Bool

true while the game should suppress its keybinds (a widget captures typing).

staticread onlymouseBlocked:Bool

true while the game should ignore its own mouse input (pointer owned by the UI).

@:value(null)staticread onlyroot:UIRoot = null

The bridged root, or null before init.

@:value(null)staticonOverUIChanged:Bool ‑> Void = null

Fired when the pointer enters/leaves the UI (custom cursor-art swaps).

Static methods

@:value({ offsetY : 0, offsetX : 0 })staticanchor(target:DisplayObject, worldX:Float, worldY:Float, ?camera:FlxCamera, offsetX:Float = 0, offsetY:Float = 0):Void

Pins a display object (widget or plain sprite already in the UI tree) to a world point; it follows camera scroll/zoom every frame until unanchored. Re-anchoring the same target updates its record in place.

Parameters:

target

the display object to reposition

worldX

the world-space anchor x

worldY

the world-space anchor y

camera

the camera to track (null = FlxG.camera)

offsetX

UI-space x offset applied after projection (e.g. -target.width / 2)

offsetY

UI-space y offset applied after projection

staticdispose():Void

Full teardown: unhooks signals, restores mouse state and disposes the root. Call from the state's destroy (or before re-init).

@:value({ aboveGame : true })staticinit(aboveGame:Bool = true):UIRoot

Creates and attaches the UIRoot, hooking the Flixel signals the bridge needs.

Parameters:

aboveGame

true (recommended) parents the root inside FlxG.game below the cursor container — UI coordinates equal game coordinates automatically; false attaches to the stage and syncs setViewport from the active scale mode on resize (use when FlxG.game carries filters/shaders that must not affect the UI)

Returns:

the created root

staticsyncViewport():Void

Re-syncs the stage-attached root over the Flixel game viewport (no-op when the root is parented inside FlxG.game). Called automatically on gameResized.

staticinlineuiToWorldX(uiX:Float, ?camera:FlxCamera):Float

Converts a UI/game x coordinate to world space through a camera (inverse of worldToUIX; e.g. spawning at a clicked UI position).

Parameters:

uiX

the UI-space x

camera

the camera to unproject through (null = FlxG.camera)

Returns:

the world-space x

staticinlineuiToWorldY(uiY:Float, ?camera:FlxCamera):Float

Converts a UI/game y coordinate to world space through a camera.

Parameters:

uiY

the UI-space y

camera

the camera to unproject through (null = FlxG.camera)

Returns:

the world-space y

staticunanchor(target:DisplayObject):Void

Stops tracking an anchored display object (does not remove or dispose it).

Parameters:

target

the same object passed to anchor

staticinlineworldToUIX(worldX:Float, ?camera:FlxCamera):Float

Converts a world x coordinate to UI/game space through a camera (assumes the default FlxG.initialZoom == 1 setup; zoom scales around the viewport centre).

Parameters:

worldX

the world-space x

camera

the camera to project through (null = FlxG.camera)

Returns:

the x in UI coordinates

staticinlineworldToUIY(worldY:Float, ?camera:FlxCamera):Float

Converts a world y coordinate to UI/game space through a camera.

Parameters:

worldY

the world-space y

camera

the camera to project through (null = FlxG.camera)

Returns:

the y in UI coordinates