From 1fc0c00e8b237d929e50c509c6ca6e70a6dbc53c Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Thu, 4 Jun 2015 18:58:36 +0900 Subject: [PATCH] make it so Touch DPad support does not need offsets. You can pass in offsetX and offsetY to the center of the DPad but otherwise it will assume the center of the element that represents the DPad --- public/hft/0.x.x/scripts/misc/touch.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/hft/0.x.x/scripts/misc/touch.js b/public/hft/0.x.x/scripts/misc/touch.js index 78907b74..ab048576 100644 --- a/public/hft/0.x.x/scripts/misc/touch.js +++ b/public/hft/0.x.x/scripts/misc/touch.js @@ -253,8 +253,8 @@ define( var padOptions = options.pads[padId]; pad.pointerId = e.pointerId; var relPos = Input.getRelativeCoordinates(padOptions.referenceElement, e); - var x = relPos.x - padOptions.offsetX; - var y = relPos.y - padOptions.offsetY; + var x = relPos.x - (padOptions.offsetX || padOptions.referenceElement.clientWidth / 2); + var y = relPos.y - (padOptions.offsetY || padOptions.referenceElement.clientHeight / 2); if (options.fixedCenter) { pad.pointerStartPos.reset(0, 0); pad.pointerPos.reset(x, y); @@ -300,8 +300,8 @@ define( if (pad.pointerId === e.pointerId) { var padOptions = options.pads[ii]; var relPos = Input.getRelativeCoordinates(padOptions.referenceElement, e); - var x = relPos.x - padOptions.offsetX; - var y = relPos.y - padOptions.offsetY; + var x = relPos.x - (padOptions.offsetX || padOptions.referenceElement.clientWidth / 2); + var y = relPos.y - (padOptions.offsetY || padOptions.referenceElement.clientHeight / 2); pad.pointerPos.reset(x, y); pad.vector.copyFrom(pad.pointerPos); pad.vector.minusEq(pad.pointerStartPos);