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

[2.1.3] Polygon.contains - Cannot read property 'y' of undefined #1267

Closed
BurnedToast opened this issue Oct 28, 2014 · 2 comments
Closed

[2.1.3] Polygon.contains - Cannot read property 'y' of undefined #1267

BurnedToast opened this issue Oct 28, 2014 · 2 comments

Comments

@BurnedToast
Copy link

Hi,

I get an error that can be reproduced with the following snippet:

var poly = new Phaser.Polygon([
    new Phaser.Point(250, 0),
    new Phaser.Point(50, 0),
    new Phaser.Point(0, 100),
    new Phaser.Point(275, 100),
    new Phaser.Point(250, 0)
]);
poly.contains(50, 50);

The error stack is;

Uncaught TypeError: Cannot read property 'y' of undefined phaser.js:15457
Phaser.Polygon.contains phaser.js:15457

Thats Polygon.js line 100

pnstickne added a commit to pnstickne/phaser that referenced this issue Oct 29, 2014
- Finished conversion of code to 'pairs' points, internally refered to as `_pairs`.
- Removed double-usage of `points` and added deprecation in favor of `setTo/getPoints` which better expose the behavior.
- Fixed/reverted 1e3c7cf (the toggle is required for this algorithm)
- Updated/unified documentation
@pnstickne
Copy link
Contributor

There was a little regression with the code; some of it had been updated to PIXI's new format, but not all of it.

photonstorm added a commit that referenced this issue Oct 29, 2014
…issues (thanks @pnstickne for the original implementation #1267)

Polygon.area is now only calculated when the Polygon points list is modified, rather than on every call.

Phaser.Polygon can now accept the points list in a variety of formats: Arrays of Points, numbers, objects with public x/y properties or any combination of, or as a parameter list (thanks @pnstickne for the original implementation #1267)

Polygon.contains now correctly calculates the result  (thanks @pnstickne @BurnedToast #1267)
@photonstorm
Copy link
Collaborator

This is now fixed in the dev branch. Thanks for reporting!

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