Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collisions is not a constructor #1

Closed
IceHacks opened this issue Oct 9, 2018 · 5 comments
Closed

Collisions is not a constructor #1

IceHacks opened this issue Oct 9, 2018 · 5 comments

Comments

@IceHacks
Copy link

IceHacks commented Oct 9, 2018

My code is simply

var Collisions = require("detect-collisions");

var system = new Collisions();
var result = system.createResult();

but I get the error TypeError: Collisions is not a constructor. I know what that means but Collisions is supposed to be a constructor. Also when trying it without the new it says Collisions is not a function. I probably made an obvious mistake but I can't find it.

Edit
When console.loging Collisions everything looks defined and default is a function.

Edit #2

var Collisions = require("detect-collisions").default;

var system = new Collisions();
var result = system.createResult();

Adding .default works for some reason.

@zhuravlenko2555dev
Copy link

thanks for help

@Prozi
Copy link
Owner

Prozi commented Oct 14, 2018

Sorry there was error in the documentation :(

Please use like:

const {Collisions} = require('detect-collisions');

const system = new Collisions();

Please update to version 2.4.3 the docs are up to date now

@Prozi
Copy link
Owner

Prozi commented Oct 14, 2018

// other options:
const Collisions = require('detect-collisions').default;
import Collisions from 'detect-collisions';

@Prozi
Copy link
Owner

Prozi commented Oct 14, 2018

this is because there is more to the engine than just Collisions, there are

Circle: function()
Collisions: function()
Point: function()
Polygon: function()
Result: function()
default: function() // equal to Collisions

@Prozi Prozi closed this as completed Oct 14, 2018
@IceHacks
Copy link
Author

Thank you. If I only watched my email I would've seen this before giving up xD. My projects are gone now anyways (I had a PC problem)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants