diff --git a/README.md b/README.md index 2682a605d..6b14c80f1 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ Thanks to @pnstickne for vast majority of this update. * Timer.update was calling the TimerEvent callback even if `TimerEvent.pendingDelete` was already set to `true`, causing timer events to stack-up in cases where a new TimerEvent was generated in the callback (thanks @clowerweb #838) * Pointer.stop would call `event.preventDefault` if `Pointer._stateReset` was `true`, which is always `true` after a State has changed and before Pointer.start has been called. However this broken interacting with DOM elements in the case where the State changes and you immediately try to use the DOM element without first having clicked on the Phaser game. An additional guard was added so `preventDefault` will now only be called if both `_stateReste` and `Pointer.withinGame` are true (thanks @satan6 #1509) * Group.forEach (and many other Group methods) now uses the `children.length` value directly instead of caching it, which both helps performance and stops the loop from breaking should you remove a Group child in the invoked callback. +* Phaser.Ellipse.contains is now working again (thanks @spayton) For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md). diff --git a/src/geom/Ellipse.js b/src/geom/Ellipse.js index 06592d857..2ab15cb06 100644 --- a/src/geom/Ellipse.js +++ b/src/geom/Ellipse.js @@ -276,21 +276,20 @@ Object.defineProperty(Phaser.Ellipse.prototype, "empty", { * @return {boolean} True if the coordinates are within this ellipse, otherwise false. */ Phaser.Ellipse.contains = function (a, x, y) { - - if (a.width <= 0 || a.height <= 0) - { + + if (a.width <= 0 || a.height <= 0) { return false; } - - // Normalize the coords to an ellipse with center 0,0 - var normx = ((x - a.x) / a.width); - var normy = ((y - a.y) / a.height); - + + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 + var normx = ((x - a.x) / a.width) - 0.5; + var normy = ((y - a.y) / a.height) - 0.5; + normx *= normx; normy *= normy; - - return (normx + normy <= 1); - + + return (normx + normy < 0.25); + }; // Because PIXI uses its own Ellipse, we'll replace it with ours to avoid duplicating code or confusion.