Theme and skin systems for 2D games
themesskinspixel-artspritesgame-architectureeditor
How Run bundles visuals into themes so levels can be reskinned wholesale, and what a pixel-art skin editor needs. The general idea: one named theme owns every visual slot; individual objects never pick their own skin.
What a theme contains
- World skin slots (14 in Run): tiles for platform, hazard surface, scenery; sprites for exit, coin, checkpoint (unreached + reached, usually a green variant), bike pickup, bike ride, key, portal, and one per hazard entity (chaser, turret, swooper). Adding a new entity type means adding a slot.
- Background: procedural Component (preferred for built-ins; richer animation) or a data-driven layer list for user themes (Visual effects in Flame (particles, effects, decorators, shaders)).
- Player skin: 8 required animation states: idle, run1, run2, jump, fall, dash, wallSlide, sad.
- Possibly music per theme.
Example coherent themes: Industrial (diamond plate, fire, garage-door exit, gear coins, cone checkpoint, forklift "bike", hard-hat player), Dungeon (stone, spikes, cell door, chalice, minecart, skeleton), Space (hull plating, plasma, airlock, crystal orb, rocket, astronaut), Jungle, Underwater. The "vehicle" slot reinterpreted per theme is a nice touch.
Design rules
- Skins come from the theme only; no per-instance skin pickers (they were removed from Run's editor as confusing).
- Bundle a theme explicitly (
CustomTheme{name, worldSkin, playerSkin, background}) instead of implicitly matching separately stored skins by name; migrate name-matched legacy skins into bundles on first load. - A theme preview should show many items at once (tiled platform, hazard, player on a platform, start and exit markers, pickup, portal, background), not just a platform.
- Reference themes by id, not display name, and embed referenced art when publishing a level, or other players see missing or stale skins (Run's republish skipped art whose key already existed).
- Built-in theme lists should be built once (a lazy final), not by a getter that rebuilds pixel grids on every access.
Pixel-art skin editor features worth having
Pencil, eraser, flood fill, eyedropper (auto-returns to pencil), Bresenham line with live preview, color replace (all matching pixels), rectangle selection with copy/paste/flip, horizontal mirror mode, right-click always erases, frame flip/rotate/copy between states, grid sizes 16/24/32/48, undo/redo, keyboard shortcuts. Extract one shared pixel-canvas widget for the player and world skin editors. Store pixel grids compactly (hex strings) and expect localStorage quota errors on web.
Sprite sheets from existing art
Run's first character came from JPEG pixel art: a Pillow script cropped each frame into a 6x6
sheet and turned white into transparency. Render with FilterQuality.none.
See also
- Building an in-game level editor (Flutter)
- Game content data models (stable ids, schemas, serialization)