learningPixi icon indicating copy to clipboard operation
learningPixi copied to clipboard

Error in "PIXI.loader.add"

Open duqingnian opened this issue 3 years ago • 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

duqingnian avatar Jan 15 '21 01:01 duqingnian

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.

DennysOliveira-2 avatar Jan 23 '21 01:01 DennysOliveira-2

You can refer to https://pixijs.download/dev/docs/PIXI.Loader.html

ygj6 avatar Mar 27 '21 08:03 ygj6