Pause-Gamesflow
Pause-Games/flow/flow.layout
Flow's flexbox layout pass, which computes the position and size of every element in a tree.
- GitHub: Pause-Games/flow — pinned to
1.0.0- Pick a release from Pause-Games/flow releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as layout from "flow.layout"
- Pick a release from Pause-Games/flow releases and add its Source code (zip) URL (or a packaged
Functions
compute(node: Flow_Element, x: number, y: number, w: number, h: number)
Compute layout for a node tree. Writes layout.x/y/w/h to every node in the tree recursively, using bottom-left origin coordinates.
Algorithm:
- Measure all regular (non-overlay) children to sum fixed sizes and flex_grow weights.
- Distribute remaining free space according to justify_content.
- Place each child along the main axis, applying align_items / align_self on the cross axis.
- Recurse into each child.
- Layout overlay children (popup, bottom_sheet) at full parent bounds as a final pass.
Parameters
node:Flow_Element— The root element to compute layout forx:number— Left edge of the available area in layout space (px)y:number— Bottom edge of the available area in layout space (px)w:number— Available width in pixelsh:number— Available height in pixels