Guide

Node editor

Build logic by joining blocks instead of writing code.

Open it

A UI app project includes logic/main.wiinodes with a working click counter. Double-click it. Add another with File > New > Wii Homebrew > Node Graph.

The node editor showing a click counter built from joined blocks
A click counter. Press the button, add one, show it in a label.

How it works

  • Add Node adds a block. Drag between two ports of the same colour to join them.
  • White wires are the order things happen in. Start at a red event block.
  • Coloured wires carry values: blue numbers, green text, orange Boolean (yes/no), purple vectors.
  • An input with nothing joined shows a box where you type a value.
  • Drag a title to move a node. Drag the background to draw a box and select the nodes in it (hold Shift to add to the selection); dragging any selected node moves them all. Delete removes the selected nodes.
  • Pan by dragging with the middle mouse button, with a trackpad's two-finger scroll, or with the scroll bars at the edges.
  • Zoom with the mouse wheel, the − and + buttons, ⌘− / ⌘= or a trackpad pinch. Fit All zooms and pans so every node is on screen.
  • Right-click a node to Duplicate it, Disconnect All Wires or Delete it. Right-click an input to disconnect just that wire.

Blocks

  • Events: On Start, On Every Frame, On Draw, On Button Pressed, On Wii Remote Button.
  • Flow: Branch (true, false, then regardless), Repeat, Exit App.
  • Widgets: get or set text, set visibility or colour, get or set position, move, get size.
  • Variables: a Get and a Set for each of number, text, Boolean and vector, plus Toggle to flip a Boolean.
  • Game: draw a rectangle, text or sprite, play a sound, play or stop music (a .brstm in assets/). Input: button held or pressed, stick, pointer.
  • Values and maths: numbers, text, vectors, variables, add, subtract, compare, random, join text, and more.
  • Text: Join Text, Text Equals, and Number, Boolean, Vector and Colour to Text to show any value in a label or on screen.

Frame rate

In the program graph, open the Graph menu and choose a Frame rate: 60 (the default), 30, 20, 15 or 10 frames per second. Slower rates give heavy games more time per frame, but everything that moves per frame moves less often, so adjust your speeds to match. Swift code can call setFrameRate(30).

Screen coordinates

In the node editor, 0, 0 is the bottom left of the screen and Y counts up (the Origin menu in the top bar switches a graph back to top left; graphs made before this option started there). Draw, sprite, text, pointer and widget-position nodes all follow this, and Get Screen Size gives the screen's width and height as a vector. Graphs made before this change keep their old top-left origin.

Vectors and colours in draw blocks

Draw Rectangle, Draw Text and Draw Sprite take a position vector (and a size vector for rectangles) instead of separate x, y, width and height. Type x, y in the box or wire in a vector. Colours work the same way: the colour input has a picker, or wire in a Colour block, which has its own picker and also takes R, G and B from numbers or variables (0 to 255). Set Color takes a colour too. Old graphs are converted when opened.

UI screens

Every .wiiui file in the project is a screen, named after its file (main.wiiui is the first one shown). Use Switch UI Screen to show another; only the current screen's widgets are drawn and clickable. Widget names must be unique across screens. Create more with New > UI Design.

Tidying up

  • Cleanup arranges every node into neat left-to-right columns, one block per event, with value nodes next to what uses them.
  • Add Box draws a labelled, coloured box to group nodes. Type its name in the title bar, drag the title bar to move the box and everything inside it, drag the corner to resize, and right-click for colours.
  • Analyze looks for blocks that never run, events and functions that do nothing, unused variables and values, maths that could be worked out in advance, and decisions that never change. Tick what you want and press Perform Suggestions; undo reverses it all in one step.

When the app is built, those clean-ups, fixed maths and always-the-same decisions are also applied automatically, and variables nothing uses are left out, so the generated code stays small and quick.

Sprite actors

To make many copies of one sprite (bullets, enemies, coins), give it its own logic file. Choose New > Sprite Actor, or set an existing graph's Type to Sprite Actor in the top bar, then pick its Sprite from your assets/ folder. The file's name is the actor's name.

  • In the actor's own graph, On Spawn runs once when a copy is created and On Update runs every frame for each copy. The sprite draws itself.
  • The actor graph's variables belong to each copy, so every bullet can have its own speed or timer.
  • Get / Set Self Position, Move Self and Destroy Self work on the copy that is running. Touching Sprite is true when the copy overlaps any copy of another actor (or its own kind), and Destroy Touching Sprites removes them, and Destroy All removes every copy of an actor, from any file.
  • Bounds is a rectangle (x, y, width, height), available as a variable and from Make Bounds (four numbers) or Make Bounds (Vectors) (a position and a size). Set Bounds and Set Bounds (Vectors) change a Bounds variable. Bounds In Sprite is true when a bounds overlaps any copy of an actor, and Sprites Overlap is true when any copy of one actor overlaps any copy of another. Both have a Fully inside tick box: ticked, the bounds (or the first actor) must lie entirely within the sprite (or the second actor), not just touch it.
  • In your main graph (or inside another actor) use Spawn Sprite, pick the actor, and give it a position. Up to 64 copies of each actor can exist at once.

Sprite positions are the sprite's bottom-left corner, counting up from the bottom of the screen. Sprite actors can't use functions or the main program's events yet.

Functions

Add a Define Function node, name it, and build what it does underneath it. Use Call Function anywhere to run it, then carry on. Functions share the graph's variables.

Easing with sine, cosine and tangent

Sine, Cosine and Tangent take an angle (in degrees or radians). Feed in Frame Count or a variable that counts up to get a smooth back-and-forth value for bobbing, pulsing or orbiting things.

Variables

The Variables panel holds numbers, text, Boolean (yes/no) or vector values that last while the app runs. Read them with Get blocks and change them with Set blocks.

Press Global on a variable to make it global: the program's logic and every sprite actor read and change the same single value. Each shared name can be defined in one file only.

A vector is an x and y pair, like a position or a speed. Type it as x, y (for example 5, 6) or build one with Make Vector. Split Vector gives back x and y, and Get Widget Position / Get Widget Size give a widget's position and size as vectors. Set Widget Position puts a widget at a vector and Move Widget shifts it by one. Also: and Add Vectors, Subtract Vectors, Scale Vector and Vector Length do the maths.

If a build stops

A block that names a widget, sprite, sound or variable that doesn't exist stops the build, and the Console says which. Use Repeat for loops.