What you see
While the atlas loads, the Console prints Invalid Texture Atlas JSON Hash given, missing 'frames' Object. The texture registers with only its base frame, and any lookup by frame name comes back empty or falls back to the first frame. Animations built from the atlas run with missing frames, sprites show the wrong tile, and the missing-frame warning follows once the animation tries to resolve names that were never parsed.
Why it happens
Phaser's Hash atlas parser expects a JSON object whose top level contains a frames object keyed by frame name. The parser checks for that key first; when it is absent, it aborts the parse and keeps only the __BASE frame, so every named frame later in the file is ignored. The missing key usually means one of four mismatches. The atlas was exported in Array format, a JSON whose top level holds a frames array of records, but the code feeds it through the Hash loader, or the reverse. The JSON was truncated, hand-edited, or saved as text so its structure no longer parses as the expected object. The request returned an HTML error page or a redirect body instead of the JSON file, and the parser tried to read that markup as atlas data. Or the JSON and the image were paired under mismatched keys, so the atlas that loads does not match the texture the animation references.
A re-export from the packing tool is the most common time for this to surface, because the exporter's format option can change between projects, and an old loader config kept from the previous atlas then points at the new structure. The JSON can also look almost correct at a glance: a frames entry may exist one level deeper, or the file may use the Array records while the code expects name keys.
Confirm it
Open the atlas JSON in a text editor and read its top-level keys. A Hash atlas exposes an object under frames, with entries keyed by frame name; an Array atlas exposes frames as a list of records that each carry a filename field. Check the browser Network panel for the JSON request and confirm the response status is 200 and the body is JSON rather than an HTML error page. Also confirm the loader call passes both the image and the JSON under matching keys.
this.load.atlas('hero', 'assets/hero.png', 'assets/hero.json');
After it loads, print the frame names the texture actually holds:
this.textures.get('hero').getFrameNames().forEach(function (name) {
console.log(name);
});
A healthy Hash atlas lists named frames such as walk_1, walk_2. A broken one lists only the base frame, or an empty list, which confirms the parser stopped before reading the frames object.
Fix it
Match the exporter format to the loader you call, and repair the JSON before pairing it with the image:
- Confirm the tool exported a Hash JSON when you load with the name-based path, or an Array JSON when the config expects records; do not mix the two.
- Validate the JSON syntax for truncation, stray commas, or escaped quotes, and re-export from the packing tool if the file was hand-edited.
- Check the Network response so the request returns JSON with a matching content type, not an error page or a redirect.
- Keep the JSON key and the image key aligned in the
this.load.atlascall, and reload the texture after correcting the file.
After the change, verify in code rather than by watching the canvas: log frameTotal and check that each expected frame name returns true from has, and confirm the parser warning no longer appears in the Console on load.
The exact engine message and source location for this atlas warning are documented in the error reference.
Top comments (0)