Game UI

Game UI in Nox

Nox draws the interface of a 2D game: the HUD over the level, menus, inventories, shops, dialog boxes, and the flat art they are made of. It gives that work what a game's interface asks for and an app's does not: pictures cut in nine, screens with safe areas, buttons with states, and an export an engine can read.

A HUD, an inventory and a shop card, drawn in Nox
A HUD, an inventory and a shop card, drawn in Nox

What Nox does, and what it does not#

Nox works in two dimensions. You draw frames, shapes, paths, text and pictures, and you export them as flat pictures with the numbers an engine needs to place and stretch them.

  • It does: HUDs, menus, inventories, shops, title and pause screens, buttons with states, panels that resize without stretching their corners, icons, and flat art such as a backdrop made of shapes.
  • It does not: model, rig or light a 3D scene, and it is not a level editor. The level art in these articles is a few flat shapes that stand in for the game behind the HUD.

Lighting & Depth, in the inspector, is a soft shadow and a lit edge on a flat thing, such as a button that stands off its panel. It is not 3D lighting.

The Game UI section of the inspector#

Select anything with a size and look in the inspector, under Lighting & Depth, for Game UI. The section is shut at first. Press its plus to open it. While it is shut, the line after its title says what the selection already uses, such as · safe area, slice.

The Game UI section, open for a picture cut in nine
The Game UI section, open for a picture cut in nine

Open, it shows only what the selection can have:

ControlForWhat it does
Keep proportionsAnything with a sizeThe node keeps its width to height however it is resized
Safe T, B, L, RA frame or componentHow far in from each edge the frame keeps clear. See Safe areas
Slice L, R, T, BA picture, a frame, a shapeWhere it is cut in nine. See Nine-slice
Stretch / TileA picture or a shapeHow the sides and the middle are laid
OverflowA frame or componentWhich ways its content scrolls in Review and Play: None, Horizontal, Vertical, Both

The section stays open or shut as you left it while you select other things.

Frame presets for games#

Press F for the Frame tool. The strip at the top left of the canvas lists screens. A click makes the frame in the middle of the view, with its safe area already set.

The frame tool's strip: screens of apps, then of games, then icons
The frame tool's strip: screens of apps, then of games, then icons
PresetSizeSafe area it sets
1080p1920 × 1080Title-safe 96 and 54, action-safe 67 and 38
1440p2560 × 1440Title-safe 128 and 72, action-safe 90 and 50
2532×1170A phone held sideways141 at each end, 63 below
2796×1290A larger phone held sideways177 at each end, 63 below
4:31024 × 768Title-safe 51 and 38, action-safe 36 and 27

Design at the size the game renders its interface at. For a console or desktop game that is most often 1920 × 1080.

From design to engine#

A workflow that holds up on a real project:

  1. Make the screen. Start from a preset so the safe area is there from the first minute.
  2. Draw the parts once. A panel texture cut in nine serves every dialog. A button made a component serves every menu.
  3. Give buttons their states. Normal, Pressed, Disabled and Selected, as variants of one component. See Button states.
  4. Pin the layout. Each cluster of the HUD holds to its own corner or edge, so the screen survives another aspect ratio. See Build a 2D game HUD.
  5. Try it. Switch to Review with ⌘2 or Play with ⌘3 and press the buttons.
  6. Export. PNG or WebP at 1×, 2× and 3×, with a slice file beside each picture. See Export for a game engine.
By hand
  1. Press F and choose 1080p in the strip.
  2. Open Samples on the rail and choose Mini game GUI or Game UI: nine-slice and export to see finished examples. Each opens as a copy you can take apart.
  3. Select a panel in the sample, open Game UI in the inspector, and change a Slice number to see what it holds.
With an agent

Tell the agent the screen size and the genre, and ask for the safe area by name. It makes the screen with create_nodes, and the frame carries the same safe area the 1080p preset gives.

Make a 1920 × 1080 frame named "Pause Menu" for a 2D platformer, dark navy,
with the title-safe and action-safe areas of a television.

The agent calls create_nodes with:

{
  "nodes": [
    {
      "kind": "frame",
      "name": "Pause Menu",
      "x": 0,
      "y": 0,
      "width": 1920,
      "height": 1080,
      "fills": ["#101522"],
      "safe_area": [54, 96, 54, 96, 38, 67, 38, 67]
    }
  ]
}
Note

Nox comes with no icon set and no game art. Bring in the project's own sprites and icons as components: see Bring in your own icons.