I have really enjoyed all the dialogue so far with the questions and answers to my questions. This is an awesome community.
Today, I seem to be having a possible rounding issue with translating mousexy coordinates back to the exact isometric tile. I use two functions:
public RPGUtil.point ScreenToIsoPos(int screenX, int screenY)
float isoX = (((float)screenX) / ((float)this.terrain_width / 2.0f) + ((float)screenY) / ((float)this.terrain_height / 2.0f)) / 2.0f;
float isoY = (((float)screenY) / ((float)this.terrain_height / 2.0f) - ((float)screenX) / ((float)this.terrain_width / 2.0f)) / 2.0f;
return new RPGUtil.point((short)Math.floor(isoX), (short)(Math.floor(isoY)));
I have tried floor() and round() and it does the same thing.
public RPGUtil.point VirtualScreenToIsoPos(int screenX, int screenY)
Point xy = new Point(screenX,screenY);
return this.ScreenToIsoPos(xy.x, xy.y);
The issue seems to be if the mouse is toward the edges of the tile it *should* be on, it hops over to the adjacent tile.
Any one else fixed this issue?