Skip to content

Commit ee1e4f1

Browse files
committed
InputManager.hitTest will now factor the game resolution into account, stopping the tests from being offset if resolution didn't equal 1. phaserjs#3376
1 parent 77357db commit ee1e4f1

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* Fixed bug in `DataManager.merge` where it would copy the object reference instead of its value (thanks @rexrainbow)
1818
* The SceneManager no longer copies over the `shutdown` and `destroy` callbacks in createSceneFromObject, as these are not called automatically and should be invoked via the Scene events (thanks @samme)
1919
* The default Gamepad Button threshold has been changed from 0 to 1. Previously the value of 0 was making all gamepad buttons appear as if they were always pressed down (thanks @jmcriat)
20+
* InputManager.hitTest will now factor the game resolution into account, stopping the tests from being offset if resolution didn't equal 1 (thanks @sftsk)
2021

2122
### Updates
2223

src/input/InputManager.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ var InputManager = new Class({
381381

382382
var point = { x: 0, y: 0 };
383383

384+
var res = this.game.config.resolution;
385+
384386
for (var i = 0; i < culledGameObjects.length; i++)
385387
{
386388
var gameObject = culledGameObjects[i];
@@ -390,8 +392,8 @@ var InputManager = new Class({
390392
continue;
391393
}
392394

393-
var px = tempPoint.x + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX;
394-
var py = tempPoint.y + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY;
395+
var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX;
396+
var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY;
395397

396398
TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point);
397399

0 commit comments

Comments
 (0)