{"record":{"id":"53d82a96ea3ba1ef","repo":"phaserjs/phaser","slug":"texturemanager-spritesheet-invalid-framewidth-giv","errorCode":null,"errorMessage":"TextureManager.SpriteSheet: Invalid frameWidth given.","messagePattern":"TextureManager\\.SpriteSheet: Invalid frameWidth given\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/textures/parsers/SpriteSheet.js","lineNumber":44,"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] - The frame to start extracting from. Defaults to zero.\n * @param {number} [config.endFrame=-1] - The frame to finish extracting at. Defaults to -1, which means 'all 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 SpriteSheet = function (texture, sourceIndex, x, y, width, height, 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 === null)\n    {\n        throw new Error('TextureManager.SpriteSheet: Invalid frameWidth given.');\n    }\n\n    //  Add in a __BASE entry (for the entire atlas)\n    var source = texture.source[sourceIndex];\n\n    texture.add('__BASE', sourceIndex, 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 row = Math.floor((width - margin + spacing) / (frameWidth + spacing));\n    var column = Math.floor((height - margin + spacing) / (frameHeight + spacing));\n    var total = row * column;\n\n    if (total === 0)\n    {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/phaserjs/phaser/blob/41be1e462bc600064e498cba370bfa8c5c055a22/src/textures/parsers/SpriteSheet.js#L26-L62","documentation":"Thrown by the SpriteSheet texture parser when config.frameWidth is null (i.e. not provided). The parser slices a spritesheet into uniform cells, so a frameWidth is mandatory; without it the cut grid is undefined. Note frameHeight defaults to frameWidth, so only frameWidth is checked.","triggerScenarios":"Calling loader.spritesheet(key, url, config) with a config missing 'frameWidth'; passing config as the wrong variable or an empty object; a typo like 'frameW' instead of 'frameWidth'.","commonSituations":"New spritesheet loads where the dev forgot the frameWidth config; copy-paste from a different loader call that used different option names; loading a single image as a spritesheet by mistake.","solutions":["Provide frameWidth (and optionally frameHeight) in the spritesheet config.","Double-check the option key spelling (frameWidth, not frameW or width).","If the asset is a single image, use this.load.image instead of this.load.spritesheet.","For irregular atlases, use this.load.atlas / spritesheet-from-atlas path with the right config."],"exampleFix":"// before\nthis.load.spritesheet('player', 'img/player.png', {}); // throws\n\n// after\nthis.load.spritesheet('player', 'img/player.png', { frameWidth: 32, frameHeight: 32 });","handlingStrategy":"validation","validationCode":"function loadSpritesheet(loader, key, url, cfg) {\n  if (cfg.frameWidth == null) throw new Error('spritesheet config requires frameWidth');\n  loader.spritesheet(key, url, cfg);\n}","typeGuard":"function hasFrameWidth(cfg) { return cfg != null && cfg.frameWidth != null; }","tryCatchPattern":null,"preventionTips":["Always pass frameWidth (and frameHeight) to spritesheet loads.","Use the exact option names Phaser expects.","Use load.image for single-frame assets."],"tags":["textures","spritesheet","loader","parser","config"],"backgroundTag":null,"analyzedSha":"41be1e462bc600064e498cba370bfa8c5c055a22","analyzedAt":"2026-08-13T04:23:39.729Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}