Touch location on image sprite

Hello all,

I'm trying to find an easier way to get the location (at least x) of where an image sprite is touched. So not the location on the canvas but the location on the sprite where the upper left would be the origin (0,0). At the moment I'm using a calculation by recording the x in a global variable on canvas touchdown. Then when touching the sprite, I use that value minus the x value of the sprite on touchdown which gives me a rough location on the sprite. But there must be an easier and more accurate way? Am I overlooking something?

I need to move around 6 sprites individually but be able to locate the point where on the sprite it was touched when dragging started

Thanks for your time and ideas.

Leon

image

or

image

will return the coordinates (relative to the canvas) where the imageSprite was touched.

if you want the position "within the imageSprite" then simply calculate this based upon the placement x,y of the imageSprite.