• flash mmo斜角地图坐标转换 - [flash编程]

    2009-09-10

    Tag:

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://www.blogbus.com/chaoyueziwo21-logs/46125559.html

    public function tileToPoint(tileX:int,tileY:int):Point
    {
    var x:int = 0.5 * (tileY + tileX) * tileW;
    var y:int = 0.5 * (tileY - tileX) * tileH;

    return new Point(x,y);
    }

     

    public function pointToTile(x:int,y:int):Point
    {
    var tileX:int = Math.floor(0.5 * (x  - 2 * y - tileH)/tileH) + 1;
    var tileY:int = Math.floor(0.5 * (x + 2 * y - tileH)/tileH) + 1;
    return new Point(tileX,tileY);

    }

    分享到: