LayoutPlugin
Defined in: plugins/LayoutPlugin.ts:75
Layout management plugin for PIXI.js applications using @pixi/layout.
Integrates the @pixi/layout library to provide CSS-like layout capabilities for PIXI display objects, including flexbox, positioning, and responsive design. Automatically configures sensible default styles for consistent layout behavior.
Key Features:
- CSS Flexbox-like layout system for PIXI containers
- Responsive design capabilities with intrinsic sizing
- Automatic layout calculation and positioning
- Gap, padding, and margin support
- Transform origin and object positioning controls
- Development tools integration for layout debugging
Default Style Configuration:
- Container: Auto width/height with no gap
- Leaf: Intrinsic sizing with flex shrink enabled
- Shared: Center transform origin, row direction, stretch alignment
Example
Section titled “Example”// Plugin is automatically initialized with the application// Layout capabilities are immediately available on all containers
// Create a flexbox-style layoutconst container = new PIXI.Container();container.layout = { display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', gap: 10, padding: 20};
// Add children that will be automatically laid outconst button1 = new PIXI.Sprite(buttonTexture);const button2 = new PIXI.Sprite(buttonTexture);const button3 = new PIXI.Sprite(buttonTexture);
container.addChild(button1, button2, button3);// Children are automatically positioned using flexbox rules
// Responsive design with intrinsic sizingconst responsiveContainer = new PIXI.Container();responsiveContainer.layout = { width: '100%', maxWidth: 800, flexDirection: 'column', alignItems: 'center'};
Remarks
Section titled “Remarks”- Requires @pixi/layout package to be installed
- Provides devtools integration for layout debugging in development
- Default styles are optimized for common game UI patterns
- Layout calculations happen automatically when display objects are added/modified
- Supports both absolute and relative positioning
Extends
Section titled “Extends”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new LayoutPlugin(
id
):LayoutPlugin
Defined in: plugins/Plugin.ts:48
Parameters
Section titled “Parameters”string
= 'Plugin'
Returns
Section titled “Returns”LayoutPlugin
Inherited from
Section titled “Inherited from”Properties
Section titled “Properties”__dill_pixel_method_binding_root
Section titled “__dill_pixel_method_binding_root”__dill_pixel_method_binding_root:
boolean
Defined in: plugins/Plugin.ts:39
Inherited from
Section titled “Inherited from”Plugin
.__dill_pixel_method_binding_root
readonly
id:"LayoutPlugin"
='LayoutPlugin'
Defined in: plugins/LayoutPlugin.ts:77
Plugin identifier for framework registration
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get app():
A
Defined in: plugins/Plugin.ts:53
Returns
Section titled “Returns”A
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”options
Section titled “options”Get Signature
Section titled “Get Signature”get options():
O
Defined in: plugins/Plugin.ts:44
Returns
Section titled “Returns”O
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”addSignalConnection()
Section titled “addSignalConnection()”addSignalConnection(…
args
):void
Defined in: plugins/Plugin.ts:79
Add signal connections to the container.
Parameters
Section titled “Parameters”…SignalConnection
[]
The signal connections to add.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”ILayoutPlugin
.addSignalConnection
Inherited from
Section titled “Inherited from”clearSignalConnections()
Section titled “clearSignalConnections()”clearSignalConnections():
void
Defined in: plugins/Plugin.ts:85
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”ILayoutPlugin
.clearSignalConnections
Inherited from
Section titled “Inherited from”destroy()
Section titled “destroy()”destroy():
void
Defined in: plugins/Plugin.ts:57
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”initialize()
Section titled “initialize()”initialize():
Promise
<void
>
Defined in: plugins/LayoutPlugin.ts:105
Initializes the Layout plugin with optimized default styles. Configures the @pixi/layout system with sensible defaults for game development, including flexbox behavior, sizing, and alignment settings.
Default Configuration Details:
- Container styles: Auto-sizing with no gaps for efficient nesting
- Leaf styles: Intrinsic sizing with flex shrink for responsive behavior
- Shared styles: Center origins, row direction, and stretch alignment
- Transform origin: Set to 50% for predictable scaling and rotation
- Object position: Centered for consistent alignment behavior
Returns
Section titled “Returns”Promise
<void
>
Example
Section titled “Example”// Called automatically by the plugin system// After initialization, all PIXI containers support layout properties
const container = new PIXI.Container();container.layout = { display: 'flex', // Use flexbox layout flexDirection: 'column', // Stack children vertically gap: 10, // 10px gap between children padding: 15 // 15px padding around content};
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”postInitialize()
Section titled “postInitialize()”postInitialize(
_app
):void
|Promise
<void
>
Defined in: plugins/Plugin.ts:68
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
| Promise
<void
>