kittykatattack / learningPixi

A step-by-step introduction to making games and interactive media with the Pixi.js rendering engine.
4.4k stars 851 forks source link

Error in "PIXI.loader.add" #158

Open duqingnian opened 3 years ago

duqingnian commented 3 years ago

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

DennysOliveira-2 commented 3 years ago

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.

ygj6 commented 3 years ago

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