Input matrix updates

This commit is contained in:
Richard Davey 2017-06-19 21:58:23 +01:00
parent b4a7b9246d
commit dc05c29740
4 changed files with 21 additions and 18 deletions

View file

@ -1,4 +1,4 @@
var CHECKSUM = {
build: '39f826c0-54fe-11e7-90c1-d1d02aa41ae8'
build: '2ac4ba60-552b-11e7-965c-39a419b0ea9b'
};
module.exports = CHECKSUM;

View file

@ -126,8 +126,13 @@ TransformMatrix.prototype.transformPoint = function (x, y, point)
var tx = matrix[4];
var ty = matrix[5];
point.x = x * a + y * c + tx;
point.y = x * b + y * d + ty;
// point.x = x * a + y * c + tx;
// point.y = x * b + y * d + ty;
var id = 1 / ((a * d) + (c * -b));
point.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id);
point.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id);
return point;
};

View file

@ -11,7 +11,7 @@ var GetTransformedPoint = function (matrix, gameObject, x, y, output)
if (output === undefined) { output = { x: 0, y: 0 }; }
matrix.applyITRS(gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY);
matrix.invert();
// matrix.invert();
matrix.transformPoint(x, y, output);
// var a = matrix.matrix[0];

View file

@ -3,24 +3,22 @@
var PointWithinGameObject = function (gameObject, x, y)
{
// var width = gameObject.width;
// var height = gameObject.height;
// var x1 = -width * gameObject.originX;
var width = gameObject.displayWidth;
var height = gameObject.displayHeight;
// if (x >= x1 && x < x1 + width)
// {
// var y1 = -height * gameObject.originY;
var x1 = -width * gameObject.originX;
// if (y >= y1 && y < y1 + height)
// {
// return true;
// }
// }
if (x >= x1 && x < x1 + width)
{
var y1 = -height * gameObject.originY;
// return false;
return (x >= gameObject.x && x <= gameObject.x+gameObject.width && y >= gameObject.y && y <= gameObject.y+gameObject.height);
if (y >= y1 && y < y1 + height)
{
return true;
}
}
return false;
};
module.exports = PointWithinGameObject;