Skip to content

Commit 04990d6

Browse files
committed
Input checks for container parents
1 parent 5c69bd0 commit 04990d6

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/input/InputManager.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var Mouse = require('./mouse/MouseManager');
1212
var Pointer = require('./Pointer');
1313
var Rectangle = require('../geom/rectangle/Rectangle');
1414
var Touch = require('./touch/TouchManager');
15+
var TransformMatrix = require('../gameobjects/components/TransformMatrix');
1516
var TransformXY = require('../math/TransformXY');
1617

1718
/**
@@ -195,6 +196,16 @@ var InputManager = new Class({
195196
*/
196197
this._tempHitTest = [];
197198

199+
/**
200+
* [description]
201+
*
202+
* @name Phaser.Input.InputManager#_tempMatrix
203+
* @type {Phaser.GameObjects.Components.TransformMatrix}
204+
* @private
205+
* @since 3.4.0
206+
*/
207+
this._tempMatrix = new TransformMatrix();
208+
198209
game.events.once('boot', this.boot, this);
199210
},
200211

@@ -383,6 +394,8 @@ var InputManager = new Class({
383394

384395
var res = this.game.config.resolution;
385396

397+
var matrix = this._tempMatrix;
398+
386399
for (var i = 0; i < culledGameObjects.length; i++)
387400
{
388401
var gameObject = culledGameObjects[i];
@@ -395,7 +408,16 @@ var InputManager = new Class({
395408
var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX;
396409
var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY;
397410

398-
TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point);
411+
if (gameObject.parentContainer)
412+
{
413+
gameObject.getWorldTransformMatrix(matrix);
414+
415+
TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point);
416+
}
417+
else
418+
{
419+
TransformXY(px, py, gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY, point);
420+
}
399421

400422
if (this.pointWithinHitArea(gameObject, point.x, point.y))
401423
{

0 commit comments

Comments
 (0)