Skip to Content
defold-typescript libraries
baochungitdefold-wrap

baochungit/defold-wrap/wrap.wrap

The module a project requires to use defold-wrap: node and go wrap one GUI node or game object, or a list of them, so calls on them chain, and gui_applet creates an applet that shows scenes.

  • GitHub: baochungit/defold-wrap — pinned to 1.1.0
    1. Pick a release from baochungit/defold-wrap 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 wrap from "wrap.wrap"

Functions

node(3 overloads)

  1. (node: string | Opaque<'node'>, tree?: NodeTree): Node

    Wraps a GUI node, from wrap.node.new.

    Parameters

    • node: string | Opaque<'node'> — The node, or its id. An id is looked up in tree first, then with gui.get_node.
    • tree?: NodeTree — A table from gui.clone_tree or gui.get_tree to look an id up in.

    Returns

    • Node
  2. <const K extends string>(node: readonly K[], tree?: NodeTree): NodeList<K>

    Wraps the node with each id, keyed by the id, from wrap.node_list.new.

    Parameters

    • node: readonly K[] — The node ids.
    • tree?: NodeTree — A table from gui.clone_tree or gui.get_tree to look each id up in first. An id it lacks, or every id when it is omitted, is looked up with gui.get_node.

    Returns

    • NodeList<K>
  3. <K extends string>(node: Record<K, string | Opaque<'node'>>, tree?: NodeTree): NodeList<K>

    Wraps each node, keyed by its name, from wrap.node_list.new.

    Parameters

    • node: Record<K, string | Opaque<'node'>> — Each name, paired with a node id or a node.
    • tree?: NodeTree — A table from gui.clone_tree or gui.get_tree to look each id up in first. An id it lacks, or every id when it is omitted, is looked up with gui.get_node.

    Returns

    • NodeList<K>

go(3 overloads)

  1. (go: SceneGameObjectAddress | Hash | Url): Go

    Wraps a game object, from wrap.go.new.

    Parameters

    • go: SceneGameObjectAddress | Hash | Url — The game object's url.

    Returns

    • Go
  2. <const K extends string>(go: readonly K[]): GoList<K>

    Wraps the game object at each url, keyed by the url, from wrap.go_list.new.

    Parameters

    • go: readonly K[] — The game object urls.

    Returns

    • GoList<K>
  3. <K extends string>(go: Record<K, SceneGameObjectAddress | Hash | Url>): GoList<K>

    Wraps each game object, keyed by its name, from wrap.go_list.new.

    Parameters

    • go: Record<K, SceneGameObjectAddress | Hash | Url> — Each name, paired with a game object url.

    Returns

    • GoList<K>

gui_applet(2 overloads): GuiApplet

  1. (root_node: string | Opaque<'node'>, scene?: GuiSceneClass<object>)

    Creates an applet on a node, from wrap.gui_applet.new, and when given a scene class shows a new scene of it.

    Parameters

    • root_node: string | Opaque<'node'> — The node, or the id gui.get_node looks it up by.
    • scene?: GuiSceneClass<object> — A class wrap.gui_scene.extend returns.
  2. <F extends object = {}>(root_node: string | Opaque<'node'>, scene: GuiSceneHooks<F>)

    Creates an applet on a node, from wrap.gui_applet.new, and shows a scene built from a plain table of hooks and fields, copied onto a fresh wrap.gui_scene.extend().

    Parameters

    • root_node: string | Opaque<'node'> — The node, or the id gui.get_node looks it up by.
    • scene: GuiSceneHooks<F> — The hooks and fields, each hook seeing the scene as this.

Returns

  • GuiApplet

On this page