Howdy...
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:
1 2 3 4 5 6 7 8 9
| 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.
1 2 3 4 5 6 7 8
| public RPGUtil.point VirtualScreenToIsoPos(int screenX, int screenY) { Point xy = new Point(screenX,screenY); xy.x-=(short)(this.vp_startX)+this.terrain_width/2; xy.y-=(short)(this.vp_startY)+this.terrain_height/2; 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?