Y-axis acting differently from x-axis in libgdx

First of all, hi, new here.

This doesn’t have to do with different origins in the coordinate systems (afaik), I already accounted for that.
A previous post on the issue. http://www.reddit.com/r/javahelp/comments/174i55/yaxis_movement_behaving_differently_from_xaxis/
The code. http://pastie.org/5894953
I’m using libgdx for this and it’s just an icon that you can move either by using your arrow keys or by holding down your mouse button. The problem is that when I use setPosition() in both movement-ways the function seems to add/remove a couple of pixels. I have printed the position before setting it and once I set it it doesn’t end up where it should be.
It’s as if when I use setPosition() it multiplies the Y-value by 1.1-ish in both ways I implemented it. I don’t have 1.1 (or any number like it) anywhere in the code and when I check the variable right before sending it to setPosition it is correct. Setting it to fullscreen didn’t help.

Actually your movement code is very complicated. I don’t know why you need to multiply by 1f and divide by width or height.

I didn’t run your code, but my advice is try to don’t worry about scaling first (remove OrthographicCamera) and avoid the “1f / Gdx.graphics.getHeight()/getWidth()”.

One more, your diag never is hardly become 1 or -1 as keypressed will trigger continuely.

Yes I could probably simplify it a bit. The reason I added * 1f was because I needed it to be a float but I should probably just use (float) haha. The reason I divide by height and width is because the coordinates are between 0 and 1. 0 is one end of the screen and 1 is the other. I calculate the coordinates of the object and then I divide it to get the coordinate that the system wants. But I think this is all irrelevant, since the code for the x and y-axes are identical except for x and width being replaced by y and height. The x-axis works perfectly so by my logic the y-axis should work perfectly too. But it won’t :frowning:
Diag is supposed to become sqrt(0.5) and when I printed it before it seemed to work. Although I’ll test that once this problem is solved since now the speed when going up and down is different from going right to left so I can’t really measure it properly.
I’ll try commenting out the orthographic camera but that was in the example program when I got it so I’d expect it to work.
Edit: The only thing that happened when I removed the camera was that nothing appeared.

Try to use absolute coordinate for now to testing purpose. If it works, there’s something wrong in that calculation.

Your problem is that you’re not separating the logic from the rendering.

Scaling should be done when rendering, not when calculating the positions.

So, I found this post. http://stackoverflow.com/questions/8104364/apply-pixel-coordinates-to-screen-coordinates
I did the unproject thing and now it works! (not entirely sure what it does though)