diff --git a/src/interaction/InteractionData.js b/src/interaction/InteractionData.js index e40be15..23f3dad 100644 --- a/src/interaction/InteractionData.js +++ b/src/interaction/InteractionData.js @@ -38,12 +38,13 @@ * * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off * @param [point] {Point} A Point object in which to store the value, optional (otherwise will create a new point) + * param [globalPos] {Point} A Point object containing your custom global coords, optional (otherwise will use the current global coords) * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject */ -InteractionData.prototype.getLocalPosition = function (displayObject, point) +InteractionData.prototype.getLocalPosition = function (displayObject, point, globalPos) { var worldTransform = displayObject.worldTransform; - var global = this.global; + var global = globalPos ? globalPos : this.global; // do a cheeky transform to get the mouse coords; var a00 = worldTransform.a, a01 = worldTransform.c, a02 = worldTransform.tx, diff --git a/src/interaction/InteractionData.js b/src/interaction/InteractionData.js index e40be15..23f3dad 100644 --- a/src/interaction/InteractionData.js +++ b/src/interaction/InteractionData.js @@ -38,12 +38,13 @@ * * @param displayObject {DisplayObject} The DisplayObject that you would like the local coords off * @param [point] {Point} A Point object in which to store the value, optional (otherwise will create a new point) + * param [globalPos] {Point} A Point object containing your custom global coords, optional (otherwise will use the current global coords) * @return {Point} A point containing the coordinates of the InteractionData position relative to the DisplayObject */ -InteractionData.prototype.getLocalPosition = function (displayObject, point) +InteractionData.prototype.getLocalPosition = function (displayObject, point, globalPos) { var worldTransform = displayObject.worldTransform; - var global = this.global; + var global = globalPos ? globalPos : this.global; // do a cheeky transform to get the mouse coords; var a00 = worldTransform.a, a01 = worldTransform.c, a02 = worldTransform.tx, diff --git a/src/interaction/InteractionManager.js b/src/interaction/InteractionManager.js index 3ff4b95..aa53cf6 100644 --- a/src/interaction/InteractionManager.js +++ b/src/interaction/InteractionManager.js @@ -616,10 +616,19 @@ } var changedTouches = event.changedTouches; + var cLength = changedTouches.length; + var touchEvent; - for (var i=0; i < changedTouches.length; i++) + for (var c=0; c < cLength; c++) { - var touchEvent = changedTouches[i]; + touchEvent = changedTouches[c]; + touchEvent.global = new core.math.Point(); + this.mapPositionToPoint( touchEvent.global, touchEvent.clientX, touchEvent.clientY ); + } + + for (var i=0; i < cLength; i++) + { + touchEvent = changedTouches[i]; //TODO POOL var touchData = this.getTouchData( touchEvent ); @@ -665,10 +674,19 @@ } var changedTouches = event.changedTouches; + var cLength = changedTouches.length; + var touchEvent; - for (var i=0; i < changedTouches.length; i++) + for (var c=0; c < cLength; c++) { - var touchEvent = changedTouches[i]; + touchEvent = changedTouches[c]; + touchEvent.global = new core.math.Point(); + this.mapPositionToPoint( touchEvent.global, touchEvent.clientX, touchEvent.clientY ); + } + + for (var i=0; i < cLength; i++) + { + touchEvent = changedTouches[i]; var touchData = this.getTouchData( touchEvent ); @@ -728,10 +746,19 @@ } var changedTouches = event.changedTouches; + var cLength = changedTouches.length; + var touchEvent; - for (var i=0; i < changedTouches.length; i++) + for (var c=0; c < cLength; c++) { - var touchEvent = changedTouches[i]; + touchEvent = changedTouches[c]; + touchEvent.global = new core.math.Point(); + this.mapPositionToPoint( touchEvent.global, touchEvent.clientX, touchEvent.clientY ); + } + + for (var i=0; i < cLength; i++) + { + touchEvent = changedTouches[i]; var touchData = this.getTouchData( touchEvent );