Paperdoll layers

Composing layers in a game

Layers from separate layer assets stack, and each one is a switch: draw it or do not. The outfit, hat and sword here are three assets, generated separately, drawn over one base; the trousers, shirt, hat and placed sword further up are four.

A character in a war kilt with dragon wings, a mohawk, a torch and a greatsword turning through eight directions

  • Order. Body, then clothing from the inside out, then held items, then hat is a workable default. A placed item that belongs behind the body already has the covered part left out, so it still goes on top. A cape or a sword on the back, inpainted, wants to be drawn behind the body when the character faces the viewer and in front when it faces away; keep a small table of order per direction in your game, the way Ultima Online and Flare do.
  • Position. An unpadded layer has its source frame's canvas: same position. A padded one is larger by padding on every side: same centre.
  • Frame for frame. Layer frame N belongs to source frame N. There is one layer file per source file and the names pair them up.
  • Hidden parts are not there. A layer holds what the frame shows. Hair behind a head, an arm behind a torso, the part of a hat a raised arm would cover: none of it is drawn, so removing a layer never reveals more of the one beneath.
  • Mirrors. A layer over a mirrored loop is painted on the flipped frames, so anything one-sided (a sword, a shoulder strap) is drawn for that side rather than flipped. Dress the mirror, do not mirror the layer. A placed item on a mirrored loop is pinned by that loop's own anchors, to the hand you named.

One sheet for the game. pixelkiln pack --style <style> puts the character and every layer on one sheet, and its atlas pairs them up: a layers section names, for each frame of each layer, the frame it goes over and the offset to draw it at. See Derived artifacts. The set on this page packs to one 3360×3360 sheet of 1,216 frames with 37 layers listed, recolours included. Draw order between layers is left to the game.

layout.json in the layer's work folder lists every frame's asset, role, canvas, padding and cell, for a build step that wants to pack layers itself.