Skip to content

Better handling of 'Texture Error: frame does not fit inside the base Texture dimensions' #1556

@fyyyyy

Description

@fyyyyy

Hey there
I have a game where users can upload their own spritesheets. However when they make a mistake, e.g. a sprite that is 1 pixel too narrow, the error 'Texture Error: frame does not fit inside the base Texture dimensions' is thrown in the console. And the entire game stops loading. I currently do not see a way to try/catch that inside my game code. Is it possible to allow the the game developer to handle this exception ?
Or to provide a function to "test" assets before loading them

Thanks 👍

My current workaround is

PIXI.Texture.prototype.setFrame = function(frame)
{

   ...

    if (!this.trim && (frame.x + frame.width > this.baseTexture.width || frame.y + frame.height > this.baseTexture.height))
    {
        this.valid = false;
        return;
        //throw new Error('Texture Error: frame does not fit inside the base Texture dimensions ' + this);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions