Hello,
Newbie here, please be patient with me . I have an image as a static 2D sprite and ortographic camera pointed at it. The ortosize of the camera is set up the same way like in the samples - using PIXEL_SIZE and the height from the graphics subsystem (which is the height of the window in pixels). When I click on that sprite, I need to calculate the pixel coordinates under the mouse pointer on that image. If the camera was static and unable to zoom, the calculation could be somewhat simple, but if I use camera zoom, then I have to first recalculate the mouse coordinates to a point in the world space (following the 2D Constraints sample). To get the coordinates of the pixel under the mouse cursor I multiply the world coordinates by the dimensions of the image and some magic constant 0.05f (and I add an offset depending on what is the position of the sprite in worldspace). This works well, but I want to understand how the calculation should be done properly.
So can anyone suggest a better way? Or explain what is going on with PIXEL_SIZE, world space coordinates and that magic constant 0.05f?
Thank you.