diff --git a/Docs/logo/phaser space paint 08.png b/Docs/logo/phaser space paint 08.png new file mode 100644 index 00000000..3c8bb3f0 Binary files /dev/null and b/Docs/logo/phaser space paint 08.png differ diff --git a/Phaser/utils/CircleUtils.ts b/Phaser/utils/CircleUtils.ts index 35c26673..12a4b008 100644 --- a/Phaser/utils/CircleUtils.ts +++ b/Phaser/utils/CircleUtils.ts @@ -36,8 +36,17 @@ module Phaser { * @return {Boolean} True if the coordinates are within this circle, otherwise false. **/ static contains(a: Circle, x: number, y: number): bool { - //return (a.radius * a.radius >= Collision.distanceSquared(a.x, a.y, x, y)); - return true; + + // Check if x/y are within the bounds first + if (x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) + { + var dx: number = (a.x - x) * (a.x - x); + var dy: number = (a.y - y) * (a.y - y); + return (dx + dy) <= (a.radius * a.radius); + } + + return false; + } /** diff --git a/Phaser/utils/DebugUtils.ts b/Phaser/utils/DebugUtils.ts index a4a522e3..1d97aa99 100644 --- a/Phaser/utils/DebugUtils.ts +++ b/Phaser/utils/DebugUtils.ts @@ -96,6 +96,14 @@ module Phaser { } + static renderCircle(circle: Phaser.Circle, fillStyle: string = 'rgba(0,255,0,0.3)') { + + DebugUtils.context.fillStyle = fillStyle; + DebugUtils.context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2, false); + DebugUtils.context.fill(); + + } + static renderPhysicsBody(body: Phaser.Physics.Body, lineWidth: number = 1, fillStyle: string = 'rgba(0,255,0,0.2)', sleepStyle: string = 'rgba(100,100,100,0.2)') { for (var s = 0; s < body.shapesLength; s++) diff --git a/README.md b/README.md index cb82869d..cf554a5a 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,7 @@ TODO: * Stage CSS3 Transforms? * Ability to layer another DOM object and have it controlled by the game somehow. Can then do stacked canvas effects. * Stage lost to mute +* When game is paused Pointer shouldn't process targetObjects / change cursor @@ -157,6 +158,7 @@ V1.0.0 * Dropped the StageScaleMode.setScreenSize iterations count from 40 down to 10 and document min body height to 2000px. * Added Phaser.Net for browser and network specific functions, currently includes query string parsing and updating methods. * Added a new CSS3 Filters component. Apply blur, grayscale, sepia, brightness, contrast, hue rotation, invert, opacity and saturate filters to the games stage. +* Fixed the CircleUtils.contains and containsPoint methods diff --git a/Tests/phaser.js b/Tests/phaser.js index ff65ffdd..2cee6f41 100644 --- a/Tests/phaser.js +++ b/Tests/phaser.js @@ -20758,8 +20758,18 @@ var Phaser; * @return {Boolean} True if the coordinates are within this circle, otherwise false. **/ function contains(a, x, y) { - //return (a.radius * a.radius >= Collision.distanceSquared(a.x, a.y, x, y)); - return true; + // Check if x/y are within the bounds first + if(x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) { + var dx = a.x - x; + var dy = a.y - y; + dx *= dx; + dy *= dy; + var radSqr = a.radius * a.radius; + console.log('within bounds', dx, dy, radSqr); + return (dx + dy) <= radSqr; + //return (a.left * a.left + a.top * a.top) <= (a.radius * a.radius); + } + return false; }; CircleUtils.containsPoint = /** * Return true if the coordinates of the given Point object are within this Circle object. diff --git a/build/phaser.js b/build/phaser.js index ff65ffdd..2cee6f41 100644 --- a/build/phaser.js +++ b/build/phaser.js @@ -20758,8 +20758,18 @@ var Phaser; * @return {Boolean} True if the coordinates are within this circle, otherwise false. **/ function contains(a, x, y) { - //return (a.radius * a.radius >= Collision.distanceSquared(a.x, a.y, x, y)); - return true; + // Check if x/y are within the bounds first + if(x >= a.left && x <= a.right && y >= a.top && y <= a.bottom) { + var dx = a.x - x; + var dy = a.y - y; + dx *= dx; + dy *= dy; + var radSqr = a.radius * a.radius; + console.log('within bounds', dx, dy, radSqr); + return (dx + dy) <= radSqr; + //return (a.left * a.left + a.top * a.top) <= (a.radius * a.radius); + } + return false; }; CircleUtils.containsPoint = /** * Return true if the coordinates of the given Point object are within this Circle object.