I am using this tutorial right here… And trying to get it to work with my bottom function below. Getting a bit lost… This tutorial has a example FLA but it’s like AS2 or something and confuses the hell out of me. Going to get some sleep and give it another attempt tomorrow.
//Tile placing code…
public static function colRowToPoint(Col:int, Row:int, tileSizeX:int, tileSizeY:int):Point {
var xyPoint = new Point();
xyPoint.x = (Col - Row) * ((tileSizeX / 2) + 1);
xyPoint.y = (Col + Row) * (tileSizeY / 2);
return xyPoint;
}
//This function still needs work, not working yet...
public static function getClosestCell(Target:Point, tileSizeX:int, tileSizeY:int, mapSize:int):Object {
var tileDistX = ((tileSizeX / 2) + 1);
var tileDistY = (tileSizeY / 2);
var rowCol:Object = new Object();
rowCol.Row = Math.round((Target.x - Target.y) / tileDistX);
rowCol.Col = Math.round(((Target.x + Target.y) / 2) / tileDistY);
return rowCol;
}
Edit: Getting warmer… I think I almost solved it…