There is a pattern I've identified. It returns NaN when the mouse is to the left of the sprite (position 0,0). That is, when the returned x falls below 0 (negative), it returns NaN for the Y value (suprisingly, not the x value). Here's my console output (code is in previous message).
Below results from dragging the mouse from the right to the left. x: 560 y: 125 relX: 160.0 relY -175.0
x: 504 y: 125 relX: 104.0 relY -175.0
x: 455 y: 122 relX: 55.0 relY -177.99998
x: 413 y: 119 relX: 13.0 relY -181.0
x: 413 y: 119 relX: 13.0 relY -181.0
x: 354 y: 112 relX: -46.0 relY NaN
x: 259 y: 101 relX: -141.0 relY NaN
x: 193 y: 91 relX: -207.0 relY NaN
x: 193 y: 91 relX: -207.0 relY NaN
x: 123 y: 84 relX: -277.0 relY NaN
relX and relY are the values returned by the mapPixelToCoordsThe function seems to be limited only to x coordinates above 0;
i.e. when the method returns negative x values, it corrupts the returned y value and y become NaN. restated:it cannot return number y values when returned x is 0 or lower.
This happens when the mouse is in the left portion of the screen.
However, If I move the sprite(and the view) to the right far enough, I can get the function to work flawlessly; it works because all x values are positive. It as if there is an imaginary boundary for anything less than the x-value of 0.
For a bit, I thought this might be due using the View class and not passing it in as a parameter (for an overloaded version of the mapPixelToCoords that accepts (RenderWindow, const View). But I disabled my view and it did not fix the problem. I also tried passing in my view object using the overloaded function and could not get it to work.
edit:Here's a video of what is happening (had to use my phone on this computer, sorry).
https://www.youtube.com/watch?v=rhUNHfDgMNI&feature=youtu.beI have the sprite being rotated using the value returned from mapPixelToCoords. When it is NaN the sprite disappears (I guess because the rotation value is not possible).
Thanks so much for your help!