Mouse position with Zoom

Mar 8, 2013 at 3:32 AM
Hi there,

I modified the example "12 - Selecting locations & objects". I applied a zoom.
However, I noticed that the click position is now incorrect.

I would like to know how I can adjust the code below so that the click position remains correct with the zoom.
var puv = {
          u:event.clientX - sheetengine.canvas.offsetLeft, 
          v:event.clientY - sheetengine.canvas.offsetTop
        // transform coordinates to world coordinate system
        var pxy = sheetengine.transforms.inverseTransformPoint({
          u:puv.u +, 
          v:puv.v +
Thanks for your help
Mar 8, 2013 at 8:46 AM
Edited Mar 8, 2013 at 8:47 AM
pxy.x = (pxy.x - / zoom +;
pxy.y = (pxy.y - / zoom +;
Check out the source code of the "Holy yards" demo Crossyards game. It uses zoom and object selection with mouse clicks. You can read more info about how it is constructed (and also about the relevant code for mouse locations) here:
Mar 9, 2013 at 7:56 PM
Thank you so much,

it works great!