- Joined
- Nov 6, 2010
- Messages
- 1,560
- Reaction score
- 393
Hello /f(12^2)/!
I'm working on a small isometric game, but I'm having trouble converting the X/Y coords to the proper map coords.
The current method I'm using has major flaws, and I was wondering if someone had some code, a formula, or an explanation on how to get the proper tile. I can't simply add an event listener to each tile because all sprites are rectangular and will overlap with others, yielding the wrong result.
To create the grid, I use..
Any help is appreciated.
I'm working on a small isometric game, but I'm having trouble converting the X/Y coords to the proper map coords.
The current method I'm using has major flaws, and I was wondering if someone had some code, a formula, or an explanation on how to get the proper tile. I can't simply add an event listener to each tile because all sprites are rectangular and will overlap with others, yielding the wrong result.
To create the grid, I use..
Code:
for (var isoY:int = 0; isoY < mapArray.length; isoY++)
{
for (var isoX:int = 0; isoX < mapArray[isoY].length; isoX++)
{
if (this.mapArray[isoY][isoX] == 1)
{
var _tile:Tile = new Tile();
_tile.x = XOffset + (isoX * ((_tileWidth / 2) - 1) - (isoY * ((_tileWidth / 2) - 1)));
_tile.y = 2 + (isoX * int(_tileHeight / 2) - 1) + (isoY * int(_tileHeight / 2) - 1);
addChild(_tile);
this.tileArray[isoY][isoX] = _tile;
}
}
}
Any help is appreciated.