You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue with 'coordinateForPoint' not returning the correct coordinates for me.
I narrowed it down to this method in 'screenToTileCoords':
if (tilemap.staggerX == true) {
s = tilemap.sideLengthX
r = (tileWidth - tilemap.sideLengthX) / 2
h = tileHeight / 2
pixelX -= r
sectionX = pixelX / (r + s)
sectionY = pixelY / (h * 2)
// y-offset
if tilemap.doStaggerX(Int(sectionX)){
sectionY -= 0.5
}
Specifically: pixelX -= r. This causes pixels in the left-side tip of a flat-topped hex tile to be calculated to the previous X column. Removing this line causes pixels in the right-side tip of a flat-topped hex tile to be calculated to the next X column.
Barring any significantly more complicated calculations to figure out the column of an angled side, I split the difference with pixelX -= (r / 2) and it seems to be working 'good enough' for me. I'd appreciate your thoughts!
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to my attention! I'm currently reviewing the coordinate conversion math for before my next update - there are a few issues around this.
I have a flat-topped tilemap setup in Tiled as follows:
<map version="1.0" orientation="hexagonal" renderorder="right-down" width="16" height="16" tilewidth="75" tileheight="65" hexsidelength="40" staggeraxis="x" staggerindex="odd" nextobjectid="9">
I'm having an issue with 'coordinateForPoint' not returning the correct coordinates for me.
I narrowed it down to this method in 'screenToTileCoords':
Specifically:
pixelX -= r
. This causes pixels in the left-side tip of a flat-topped hex tile to be calculated to the previous X column. Removing this line causes pixels in the right-side tip of a flat-topped hex tile to be calculated to the next X column.Barring any significantly more complicated calculations to figure out the column of an angled side, I split the difference with
pixelX -= (r / 2)
and it seems to be working 'good enough' for me. I'd appreciate your thoughts!The text was updated successfully, but these errors were encountered: