final class FlxSmidr
package smidr.flixel
Optional Flixel bridge (compiled only when the flixel haxelib is present).
Solves the three points of friction between SmiðrUI and a Flixel host:
- Viewport —
init()parents theUIRootinsideFlxG.gamebelow 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 keepssetViewportsynced on resize. - Cursor — with a custom
FlxG.mousecursor the system cursor is hidden, so widgethoverCursors never show;cursorMode = CURSOR_SYSTEM_OVER_UIrestores the system cursor while the pointer is over UI, or assignonOverUIChangedto swap your own cursor art. - Input arbitration —
mouseBlocked/keysBlockedare the two flags the game checks before processing its own input;autoBlockMouse = truetogglesFlxG.mouse.enabledautomatically 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
staticautoBlockMouse:Bool = false
When true, FlxG.mouse.enabled is toggled off while the UI owns the pointer.
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).
staticonOverUIChanged:Bool ‑> Void = null
Fired when the pointer enters/leaves the UI (custom cursor-art swaps).
Static methods
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 ( |
offsetX | UI-space x offset applied after projection (e.g. |
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).
staticinit(aboveGame:Bool = true):UIRoot
Creates and attaches the UIRoot, hooking the Flixel signals the bridge needs.
Parameters:
aboveGame |
|
|---|
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 ( |
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 ( |
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 |
|---|
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 ( |
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 ( |
Returns:
the y in UI coordinates