-1

I tried to create an Isometric map editor and I stumbled across this problem when I generated the map :

http://postimg.org/image/atsqgu5on/

My generated map looks like the (A) scheme having some tiles offscreen . What must I change in my code to get a (B)-ish map?

This is the code I used to create the cells in my map. (32 is the tile height and width)

for (int i = 0; i <this.Height; i++)
        {
            Map[i] = new Rectangle[Width];
            miniMap[i] = new Rectangle[Width];

            for (int j = 0; j < this.Width; j++)
            {
                int x = 32 * j;
                int y = 32 * i;
                int isoX = x - y;
                int isoY = (x + y) / 2;

                Map[i][j] = new Rectangle(isoX,isoY, 64, 64);

            }

Somehow I know that the problem lies here : int isoX = x - y; but I don't know what to change in order to get my desired result. Thank you for any help.

4

1 回答 1

1

这里的问题似乎是您的系统从顶部开始构建成排的瓷砖,然后到左下角。由于您的第一个图块的初始坐标是 0,0,当它向左绘制后续行时,它们很快就会从屏幕上消失。

最简单的解决方案就是右移 x 坐标,使其从区域中间开始绘制顶部图块,同时记住我们希望图块的中心位于区域的中心,而不是左上边缘. 所以像

int isox = (Width / 2) - (tileLength / 2) + x - y;
于 2013-07-11T08:47:20.823 回答