From c5cfae01189bf2408ce3d7cf6b31ecf8b78e5bfc Mon Sep 17 00:00:00 2001 From: Jay Mattis Date: Sun, 12 Jul 2020 21:13:33 -0700 Subject: [PATCH] Fix drag coordinates with camera zoom (issue 4755) The dragX and dragY passed to 'dragStart' and 'drag' events are supported to be in world coordinates (as specified by the docs) but the coordinates used (pointer.x and pointer.y) were not transformed by the camera into world space. The drags now use pointer.worldX and pointer.worldY which are the post-transform coordinates. --- src/input/InputPlugin.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 0f8a8563d..ca3f5c70b 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -1126,8 +1126,8 @@ var InputPlugin = new Class({ input.dragStartX = gameObject.x; input.dragStartY = gameObject.y; - input.dragStartXGlobal = pointer.x; - input.dragStartYGlobal = pointer.y; + input.dragStartXGlobal = pointer.worldX; + input.dragStartYGlobal = pointer.worldY; input.dragX = input.dragStartXGlobal - input.dragStartX; input.dragY = input.dragStartYGlobal - input.dragStartY; @@ -1330,13 +1330,13 @@ var InputPlugin = new Class({ if (!gameObject.parentContainer) { - dragX = pointer.x - input.dragX; - dragY = pointer.y - input.dragY; + dragX = pointer.worldX - input.dragX; + dragY = pointer.worldY - input.dragY; } else { - var dx = pointer.x - input.dragStartXGlobal; - var dy = pointer.y - input.dragStartYGlobal; + var dx = pointer.worldX - input.dragStartXGlobal; + var dy = pointer.worldY - input.dragStartYGlobal; var rotation = gameObject.getParentRotation();