Build a GameCube skin

Six steps from an empty file to a phone controller with two sticks, a D-pad, face buttons, triggers, Z and Start. Each step shows its full source next to a preview drawn by the site's port of the SkinKit resolver. Open any step in the playground to change it.

Start the file and anchor the game screen

A source starts with a few fields about the skin, then a root group that holds everything drawn.

  • identifier and name identify the skin. gameTypes lists the systems it is for.
  • reference sets the unit. Plain numbers are points on a display whose short side is shortSide (390 here). On a larger display the unit grows, clamped between minScale and maxScale.
  • bake.traits lists the device families the classic layouts are baked for. Both iPhone families are required.
  • requires lists the features the source uses. Step 5 fills it in.

The first child is the game screen. It has a 4:3 aspect ratio. In portrait its width follows the safe area and its top stays pinned. In landscape a when rule centers it and sets its height to 80% of the safe area, and the resolver derives the width from the aspect ratio.

{
  "type": "screen",
  "id": "game",
  "role": "main",
  "aspect": 1.3333333333333333,
  "layout": {
    "size": { "width": "100%" },
    "anchor": { "to": "safeArea", "x": "center", "y": "top" }
  },
  "when": [
    {
      "orientation": "landscape",
      "layout": { "size": { "width": null, "height": "80%" }, "anchor": { "y": "center" } }
    }
  ]
}
Step 1: the screen and the safe area

Add a group in each corner

Controls that belong together go in a group. Give each group a stable id, a size, and an anchor to a bottom corner of the safe area: leading for the left hand, trailing for the right. Frames inside a group are [x, y, width, height] in the group's own coordinates, so the cluster moves as one piece.

Put one stick in each group to see where they land. Use leftThumbstick for the main stick and rightThumbstick for the C-stick. The same input names survive the classic bake.

{
  "type": "group",
  "id": "left",
  "layout": {
    "size": { "width": 146, "height": 164 },
    "anchor": { "to": "safeArea", "x": "leading", "y": "bottom" }
  },
  "children": [
    {
      "use": "std.stick",
      "id": "main-stick",
      "with": { "input": "leftThumbstick" },
      "layout": { "frame": [0, 58, 70, 70] }
    }
  ]
}
Step 2: two groups, one stick each

Fill in the standard parts

Each use picks a part, and with supplies its inputs, label and colors. A part you don't give colors to draws in the default purple. Start is anchored on its own to the bottom center, outside both groups.

{
  "use": "std.faceButton",
  "id": "a",
  "with": { "input": "a", "label": "A", "top": "#58DB9B", "bottom": "#127448" },
  "layout": { "frame": [52, 58, 48, 48] }
}
PartDrawsTakes in with
std.faceButtonRound buttoninput, label, top, bottom, glow, labelColor, shape
std.kidneyButtonKidney-shaped button, as X and Y hereSame as std.faceButton
std.pillCapsule, as Z and Start hereSame as std.faceButton
std.triggerBarShoulder barinput, label, kind, taper, top, bottom, labelColor
std.dpadFour-way pad with arrowsup, down, left, right (default to those input names), top, bottom, glow, arrowColor
std.stickAnalog stick with a knobinput, knob, top, bottom, glow
std.stickWithClickStick that also pressesinput, click, knob, top, bottom, glow
std.keypadKeySquare key for keypadsinput, label, color, labelColor, cornerRadius
Step 3: the finished controller

Put the colors in tokens and add a theme

tokens gives a value a name, and $name uses it anywhere a value of that type fits, including inside with. A theme is a set of token overrides. Pick one in the preview below to see it applied.

"tokens": {
  "body": "#755CA8", "bodyDark": "#3D2B66", "glow": "#9E7AF2",
  "accent": "#FFD45B", "accentDark": "#AD7022"
},
"themes": {
  "spice": {
    "body": "#F2803C", "bodyDark": "#8A3512", "glow": "#FFB36B",
    "accent": "#7DE0C4", "accentDark": "#1F7A63"
  }
}
{
  "use": "std.stick",
  "id": "main-stick",
  "with": { "input": "leftThumbstick", "top": "$body", "bottom": "$bodyDark", "glow": "$glow" },
  "layout": { "frame": [0, 58, 70, 70] }
}

These themes only change colors, so they bake into the same archive as artwork overrides. A theme that moves a control or a screen bakes to its own archive.

Step 4: tokens and two themes

List what the skin uses in requires

A reader checks requires before it trusts the responsive source. If it doesn't know a name in the list, it falls back to the classic layout in the same archive. The list has to match the content: the validator reports a feature the source uses and doesn't list as an error, and a listed feature it doesn't use as a warning.

The themed controller uses these:

"requires": [
  "layout.anchors", "layout.repeat", "shapes.parametric", "paint.gradients",
  "effects.shadow", "text", "parts", "tokens", "themes", "states",
  "controls.dpad", "controls.thumbstick", "parts.std@2.0"
]

Several of those come from inside the standard parts (paint.gradients, effects.shadow, states), which is easy to miss by hand. In the playground, Update requires writes the list from what the source uses.

Bake and test the archive

Save the finished source as skin.json and run the baker from a SkinKit checkout. It validates the source, then writes a .deltaskin holding the classic layouts, their artwork and the source itself.

xcrun swift run skinkit-bake /path/to/skin.json /path/to/output

Import the .deltaskin in the target app. Check both orientations, move each stick independently and check every button against its artwork. Test the same archive in a classic reader to verify the fallback. When it works, submit it to the catalog.