kittykatattack/learningPixi

Error in "PIXI.loader.add"

duqingnian opened this issue · 2 comments

when I run the "03_spriteFromImage.html" script in "examples" folder, I get this error: "Uncaught TypeError: Cannot read property 'add' of undefined", so I change "PIXI.loader.add("images/cat.png").load(setup);" to "PIXI.Loader.add("images/cat.png").load(setup);", still get the same error.
add_error

This tutorial is a little bit old for newer versions of PIXI. I think it was made to V4ish and you're currently using 6.
You should create an instance of PIXI.Loader or use the PIXI.Loader.shared that would be the "same" as the old loader.

const loader = new PIXI.Loader();
loader.add("images/tree2.png").load(setup);

That should do.