liabru / matter-js

a 2D rigid body physics engine for the web ▲● ■
MIT License
16.62k stars 1.96k forks source link

matter-attractors does not work properly due to uncaught TypeError #791

Closed J2thearo closed 4 years ago

J2thearo commented 4 years ago

Has anyone an idea what's causing this error? The matter.js and matter-attractors.js files are inside my project libraries folder. I get the feeling that it has something to do with the Webpack. I also can provide you with further details if needed. I am working with p5.js and matter.js.

Matter_error

J2thearo commented 4 years ago

I've solved it! It had nothing to do with the Webpack.

Insinde the index.html I've mentioned the refrence to matter-attractors.js before matter.js, but matter.js has to be refrenced first!

You can even see it in the warning, it says "matter-attractors used by matter-js", but its actually supposed to be the other way around.

liabru commented 4 years ago

Glad you solved it, that's right Matter should always be loaded before plugins as they will need to register themselves on it.