Skip to content

Commit 2e722b0

Browse files
committed
debugging tests
1 parent 9269aa7 commit 2e722b0

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

src/input/InputManager.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ var InputManager = new Class({
410410

411411
if (gameObject.parentContainer)
412412
{
413-
gameObject.getWorldTransformMatrix(matrix);
413+
gameObject.getWorldTransformMatrix(matrix, camera);
414414

415415
TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point);
416416
}
@@ -428,6 +428,44 @@ var InputManager = new Class({
428428
return output;
429429
},
430430

431+
debugHitTest: function (x, y, gameObject, camera, output)
432+
{
433+
if (output === undefined) { output = this._tempHitTest; }
434+
435+
var tempPoint = this._tempPoint;
436+
437+
// Stores the translated world point inside of tempPoint
438+
camera.getWorldPoint(x, y, tempPoint);
439+
440+
var point = { x: 0, y: 0 };
441+
442+
var res = this.game.config.resolution;
443+
444+
var matrix = this._tempMatrix;
445+
446+
var px = tempPoint.x * res + (camera.scrollX * gameObject.scrollFactorX) - camera.scrollX;
447+
var py = tempPoint.y * res + (camera.scrollY * gameObject.scrollFactorY) - camera.scrollY;
448+
449+
gameObject.getWorldTransformMatrix(matrix);
450+
451+
matrix.invert();
452+
matrix.transformPoint(px, py, point);
453+
454+
// var tt = new TransformMatrix();
455+
456+
// tt.translate(px, py);
457+
458+
// matrix.invert();
459+
// matrix.multiply(tt);
460+
461+
// TransformXY(px, py, matrix.tx, matrix.ty, matrix.rotation, matrix.scaleX, matrix.scaleY, point);
462+
463+
// point.x = px;
464+
// point.y = py;
465+
466+
return [ matrix, point, this.pointWithinHitArea(gameObject, point.x, point.y) ];
467+
},
468+
431469
/**
432470
* x/y MUST be translated before being passed to this function,
433471
* unless the gameObject is guaranteed to not be rotated or scaled in any way.

0 commit comments

Comments
 (0)