Skip to content

JSON Hash ​

Packrat writes TexturePacker-style JSON with an object keyed by frame name. Each page has a JSON file and an image. For several pages, JSON filenames are numbered: atlas_1.json, atlas_2.json, and so on.

json
{
  "frames": {
    "player_0000": {
      "frame": { "x": 128, "y": 64, "w": 40, "h": 48 },
      "rotated": false,
      "trimmed": true,
      "spriteSourceSize": { "x": 12, "y": 8, "w": 40, "h": 48 },
      "sourceSize": { "w": 64, "h": 64 }
    }
  },
  "meta": {
    "app": "https://www.codeandweb.com/texturepacker",
    "version": "1.0", "image": "atlas.png", "format": "RGBA8888",
    "size": { "w": 512, "h": 512 }, "scale": "1"
  }
}

The coordinates above are an example. Read the rectangle in frame from the image named by meta.image. Place those pixels at the spriteSourceSize offset, measured from the top-left of a canvas with the dimensions in sourceSize. rotated is currently false because rotated packing is disabled.

To build animation lists, group keys such as player_0000 by base name and sort the numeric suffixes. This format does not store animation lists. Keep each image beside its JSON file.

See Sources and outputs for frame names, trimming, and effect maps.

Packrat documentation