tile is far away from mouse suddenly?
Posted: Thu Jan 03, 2013 1:52 am
So, on my old tile editor, it didn't matter where the view was, the mouse would always connect to the tile. However; this happens with the same code, which is:
Now, as you can see in this screen shot this... no longer applies o.O
The ^ represents where the mouse is. I -kind of- fixed it by doing this:
but the tile appears 16 pixels away from the mouse. (I don't know why +5 and +3 need to be there but they do otherwise it doesn't align to the grid) The view's X and Y are set to -198 and -24 to make the top left corner of the grid equal to 0, 0 in X Y co-ord.
This caused the code to malfunction for some reason. I can kind of guess why, because the view goes below 0. But how to fix this?
EDIT: FIXED
FIXED ^^
- Code: Select all
x=(view.x+round(xmouse/32)*32)+16;
y=(view.y+round(ymouse/32)*32)+16;
Now, as you can see in this screen shot this... no longer applies o.O
The ^ represents where the mouse is. I -kind of- fixed it by doing this:
- Code: Select all
x=(view.x-(view.x)+round(xmouse/32)*32)+5;
y=(view.y-(view.y)+round(ymouse/32)*32)-3;
but the tile appears 16 pixels away from the mouse. (I don't know why +5 and +3 need to be there but they do otherwise it doesn't align to the grid) The view's X and Y are set to -198 and -24 to make the top left corner of the grid equal to 0, 0 in X Y co-ord.
This caused the code to malfunction for some reason. I can kind of guess why, because the view goes below 0. But how to fix this?
EDIT: FIXED
- Code: Select all
x=(view.x-(view.x)+round((xmouse+16)/32)*32)+5;
y=(view.y-(view.y)+round((ymouse+16)/32)*32)-3;
FIXED ^^