Sprite sheet file
The pixel art format Sprite Lab downloads and Ember and Delve ship, with its palette, frames, animations and rules.
Last updated
A sprite sheet is a JSON file: a palette, pixel-art sprites written as rows of characters, and the animations that play them. Sprite Lab's Download writes it, and the games' own art is in this format, written the same way.
An example
{
"version": 1,
"type": "sprites",
"palette": { "a": "#ffcc00", "k": "#1b1a2e" },
"sprites": {
"hero": {
"frames": [
[".a.", "aka", "a.a"],
[".a.", "aka", ".a."]
]
}
},
"animations": {
"hero.run": { "sprite": "hero", "frames": [0, 1], "fps": 8, "loop": true }
}
}Fields
| Field | Rules |
|---|---|
version | 1. A newer file is refused. |
type | Always "sprites" |
cognivoMayUse | Optional. true when the maker ticks Allow Cognivo to use this; absent, or anything else, means no permission. |
palette | One character for each colour, written as hex: #rgb, #rrggbb or #rrggbbaa. Any character except .. |
sprites | Each sprite is a list of frames. A frame is a list of rows of text, one character per pixel. . is transparent. Every frame of a sprite has the same width and height. |
animations | Each animation names a sprite, lists which of its frames to show in order (counted from 0), and sets fps (frames a second, 1 to 60) and loop (true, or false to hold the last frame). |
Every character in a frame must be in the palette, or the file is refused.
The shipped layout
The download writes one row of pixels per line and one line per animation, so a frame reads as a picture in a diff. The games' own art.json files are written by the same code, and a test holds them to it byte for byte.
What a game needs
A game can play a sprite sheet in place of its own art when:
- every sprite it ships that the sheet has is the same size, with at least as many frames;
- every animation it plays that the sheet has shows a sprite of the same size.
A sprite or animation the sheet doesn't have is drawn from the game's own art, in your colours where both use the same palette character. So art made before a game grew something new (a world's brazier, say) still plays. Anything extra is fine; the game just never draws it. The labs' Ready to play? checks exactly this.