From 90620e9d1f8bb1d68635d025d2025390d48c01c3 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 4 Jan 2018 00:02:48 +0000 Subject: [PATCH] Working through bounds and input issues --- v3/src/camera/2d/inc/PreRender.js | 28 ++++++++++++++++------------ v3/src/input/global/inc/HitTest.js | 15 ++++++++++++--- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/v3/src/camera/2d/inc/PreRender.js b/v3/src/camera/2d/inc/PreRender.js index 377bcb19b..18cd815cf 100644 --- a/v3/src/camera/2d/inc/PreRender.js +++ b/v3/src/camera/2d/inc/PreRender.js @@ -20,27 +20,31 @@ var PreRender = function () if (this.useBounds) { var bounds = this._bounds; - var boundsX = bounds.x; - var boundsY = bounds.y; - var boundsR = Math.max(bounds.right - width, width); - var boundsB = Math.max(bounds.bottom - height, height); - if (this.scrollX < boundsX) + // width = bounds.width; + // height = bounds.height; + + // var boundsX = bounds.x; + // var boundsY = bounds.y; + // var boundsR = Math.max(bounds.right - width, width); + // var boundsB = Math.max(bounds.bottom - height, height); + + if (this.scrollX < bounds.x) { - this.scrollX = boundsX; + this.scrollX = bounds.x; } - else if (this.scrollX > boundsR) + else if (this.scrollX > bounds.right) { - this.scrollX = boundsR; + this.scrollX = bounds.right; } - if (this.scrollY < boundsY) + if (this.scrollY < bounds.y) { - this.scrollY = boundsY; + this.scrollY = bounds.y; } - else if (this.scrollY > boundsB) + else if (this.scrollY > bounds.bottom) { - this.scrollY = boundsB; + this.scrollY = bounds.bottom; } } diff --git a/v3/src/input/global/inc/HitTest.js b/v3/src/input/global/inc/HitTest.js index dc4b33aa9..eb2c15b01 100644 --- a/v3/src/input/global/inc/HitTest.js +++ b/v3/src/input/global/inc/HitTest.js @@ -29,12 +29,21 @@ var HitTest = function (tempMatrix, x, y, gameObjects, camera, output) continue; } - var point = GetTransformedPoint( - tempMatrix, - gameObject, + tempMatrix.applyITRS(gameObject.x, gameObject.y, -gameObject.rotation, gameObject.scaleX, gameObject.scaleY); + + tempMatrix.invert(); + + var point = tempMatrix.transformPoint( screenPoint.x + camera.scrollX * gameObject.scrollFactorX, screenPoint.y + camera.scrollY * gameObject.scrollFactorY ); + + // var point = GetTransformedPoint( + // tempMatrix, + // gameObject, + // screenPoint.x + camera.scrollX * gameObject.scrollFactorX, + // screenPoint.y + camera.scrollY * gameObject.scrollFactorY + // ); if (PointWithinHitArea(gameObject, point.x, point.y, camera)) {