Jump to content



Recommended Posts

Error message:


Sprite.js:264 Uncaught TypeError: Cannot read property 'width' of null
    at e.calculateVertices (Sprite.js:264)
    at e._render (Sprite.js:361)
    at e.render (Container.js:503)
    at e.render (Container.js:508)
    at e.render (Renderer.js:361)
    at t.mo.render (Application.js:95)
    at ze.emit (TickerListener.js:96)
    at Ve.update (Ticker.js:443)
    at Ve._tick (Ticker.js:158)

Full code:

import * as PIXI from "pixijs";

export default class Game
    private _app: PIXI.Application;

    public constructor()
        //Create a Pixi Application
        this._app = new PIXI.Application({
            width: 256,
            height: 256,
            antialias: true,
            transparent: false,
            resolution: 1

        //Add the canvas that Pixi automatically created for you to the HTML document

        //load an image and run the `setup` function when it's done
            .load(() => this.Setup());

    //This `setup` function will run when the image has loaded
    private Setup(): void
        //Create the cat sprite
        let cat = new PIXI.Sprite(PIXI.Loader.shared.resources["images/cat.png"].texture);

        //You can also create the `cat` sprite from the texture, like this:
        // let cat = new PIXI.Sprite(PIXI.utils.TextureCache["images/cat.png"]);

        //Add the cat to the stage

        // This code does not work
        //If you ever need to, here's how you can clean out WebGL's GPU
        //memory manually
        Object.keys(PIXI.utils.TextureCache).forEach((texture) =>


Link to comment
Share on other sites

Well, you destroyed texture but sprite still has link to it and when app renders-> sprite renders->goodbye. There's no way to set all sprite texture to null when you destroy texture. If we make mechanism like that, it will REQUIRE everyone to use destroy() on sprites which is not requirement right now.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...