{"record":{"id":"fb02424359082937","repo":"phaserjs/phaser","slug":"texturemanager-spritesheetfromatlas-invalid-frame","errorCode":null,"errorMessage":"TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.","messagePattern":"TextureManager\\.SpriteSheetFromAtlas: Invalid frameWidth given\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/textures/parsers/SpriteSheetFromAtlas.js","lineNumber":40,"sourceCode":" * @param {object} config - An object describing how to parse the Sprite Sheet.\n * @param {number} config.frameWidth - Width in pixels of a single frame in the sprite sheet.\n * @param {number} [config.frameHeight] - Height in pixels of a single frame in the sprite sheet. Defaults to frameWidth if not provided.\n * @param {number} [config.startFrame=0] - Index of the start frame in the sprite sheet\n * @param {number} [config.endFrame=-1] - Index of the end frame in the sprite sheet. -1 means all the rest of the frames\n * @param {number} [config.margin=0] - If the frames have been drawn with a margin, specify the amount here.\n * @param {number} [config.spacing=0] - If the frames have been drawn with spacing between them, specify the amount here.\n *\n * @return {Phaser.Textures.Texture} The Texture modified by this parser.\n */\nvar SpriteSheetFromAtlas = function (texture, frame, config)\n{\n    var frameWidth = GetFastValue(config, 'frameWidth', null);\n    var frameHeight = GetFastValue(config, 'frameHeight', frameWidth);\n\n    //  If missing we can't proceed\n    if (!frameWidth)\n    {\n        throw new Error('TextureManager.SpriteSheetFromAtlas: Invalid frameWidth given.');\n    }\n\n    //  Add in a __BASE entry (for the entire atlas frame)\n    var source = texture.source[0];\n    texture.add('__BASE', 0, 0, 0, source.width, source.height);\n\n    var startFrame = GetFastValue(config, 'startFrame', 0);\n    var endFrame = GetFastValue(config, 'endFrame', -1);\n    var margin = GetFastValue(config, 'margin', 0);\n    var spacing = GetFastValue(config, 'spacing', 0);\n\n    var x = frame.cutX;\n    var y = frame.cutY;\n\n    var cutWidth = frame.cutWidth;\n    var cutHeight = frame.cutHeight;\n    var sheetWidth = frame.realWidth;\n    var sheetHeight = frame.realHeight;","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/textures/parsers/SpriteSheetFromAtlas.js#L22-L58","documentation":"Thrown by SpriteSheetFromAtlas parser when GetFastValue(config, 'frameWidth', null) is falsy. Unlike the plain SpriteSheet parser (which checks === null), this one rejects any falsy value including 0, so a frameWidth of 0 also throws. Used when slicing a single atlas frame into a grid of sub-frames.","triggerScenarios":"Calling a spritesheet-from-atlas load with config missing frameWidth; passing frameWidth: 0 (treated as missing here); mis-typing the config key.","commonSituations":"Loading an atlas JSON and then declaring a spritesheet frame inside it without frameWidth; programmatic atlas generation that omits frameWidth; confusion between the two spritesheet parser APIs.","solutions":["Set a positive integer frameWidth in the config.","Verify you are using the right parser (atlas spritesheet) vs the plain spritesheet parser.","Ensure frameWidth is not 0; pick the actual cell pixel width.","Inspect the atlas frame to confirm dimensions are >= frameWidth * columns."],"exampleFix":"// before\nthis.load.atlas('sheet', 'img/sheet.png', 'img/sheet.json');\nTextureManager.SpriteSheetFromAtlas(texture, frame, { frameWidth: 0 }); // throws\n\n// after\nTextureManager.SpriteSheetFromAtlas(texture, frame, { frameWidth: 16, frameHeight: 16 });","handlingStrategy":"validation","validationCode":"function parseSSFromAtlas(texture, frame, cfg) {\n  if (!cfg || !cfg.frameWidth) throw new Error('SpriteSheetFromAtlas requires a truthy frameWidth');\n  // proceed\n}","typeGuard":"function hasTruthyFrameWidth(cfg) { return cfg != null && !!cfg.frameWidth; }","tryCatchPattern":null,"preventionTips":["Provide a positive frameWidth for atlas spritesheets.","Distinguish this parser from the plain SpriteSheet parser.","Ensure atlas frame is large enough for the cell size."],"tags":["textures","spritesheet","atlas","parser","config"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}