Skip to Content
defold-typescript libraries
Pause-Gamesflow

Pause-Games/flow/flow.navigation.gui

The gui_script adapter that renders the current Flow screen and animates transitions between screens.

  • GitHub: Pause-Games/flow — pinned to 1.0.0
    1. Pick a release from Pause-Games/flow releases and add its Source code (zip) URL (or a packaged .zip asset, if the library ships one) to game.project under [project] dependencies, then Fetch Libraries in the Defold editor.
    2. Run bunx @defold-typescript/cli resolve to materialize its types.
    3. Import it under a namespace alias of your choice:
      import * as navigation_gui from "flow.navigation.gui"

Functions

new(navigation: Flow_Navigation): LuaTable

Create a new GUI adapter instance bound to the given navigation router. Registers listeners for "changed", "transition_begin", and "transition_complete" so the adapter stays in sync with navigation state automatically.

Parameters

  • navigation: Flow_Navigation — The navigation facade (flow/navigation/init.lua)

Returns

  • LuaTable — The adapter object with all M methods mixed in

destroy(adapter: LuaTable)

Remove all navigation listeners and clean up the adapter. Call this in gui_script final() to prevent leaking event handlers.

Parameters

  • adapter: LuaTable — The adapter instance created by M.new()

invalidate(adapter: LuaTable)

Invalidate the adapter so the next build_tree() call regenerates the tree.

Parameters

  • adapter: LuaTable — The adapter instance

needs_rebuild(adapter: LuaTable): boolean

Return true when the adapter's tree needs to be rebuilt.

Parameters

  • adapter: LuaTable — The adapter instance

Returns

  • boolean — True when adapter._needs_rebuild is set

clear_rebuild_flag(adapter: LuaTable)

Clear the rebuild flag. Called after build_tree() has been invoked.

Parameters

  • adapter: LuaTable — The adapter instance

save_scroll_state(adapter: LuaTable, tree: Flow_Element, options?: LuaTable | undefined)

Save the current scroll offsets from a UI tree into the navigation params. Typically called just before a tree rebuild so that scroll position is preserved.

Parameters

  • adapter: LuaTable — The adapter instance
  • tree: Flow_Element — The UI tree to extract scroll state from
  • options?: LuaTable | undefined — Optional {screen_id=...} to target a specific screen

build_tree(adapter: LuaTable): Flow_Element | undefined

Build (or rebuild) the UI element tree for the current navigation state. When a transition is active, renders both from and to trees and applies _alpha or _offset_x according to the transition type and eased progress.

Transition types: "fade" — cross-fade: from_tree._alpha fades out, to_tree._alpha fades in "slide_left" — to slides in from the right: from moves left, to comes from right "slide_right" — to slides in from the left: from moves right, to comes from left

Returns nil and clears adapter.tree when the stack is empty.

Parameters

  • adapter: LuaTable — The adapter instance

Returns

  • Flow_Element | undefined — The UI tree to pass to the renderer

update(adapter: LuaTable, dt: number): boolean

Advance the active transition by dt seconds. Updates transition.progress and requests an adapter rebuild each frame. When progress reaches 1.0, calls navigation.complete_transition() to signal that the transition is done and clear the busy flag.

Parameters

  • adapter: LuaTable — The adapter instance
  • dt: number — Delta time in seconds since the last frame

Returns

  • boolean — True when the transition just completed this frame

On this page