在xna中的Windows Phone的tilemap

时间:2014-01-08 15:10:46

标签: c# xna

我正在尝试使用流文件为Windows手机做平铺地图这个东西在Windows游戏中对我工作但是它不适用于Windows手机我正在使用xna任何人都可以帮助我

public void LoadMapData(string name)
{
    string path = "leveles/" + name + ".txt";

    // Width and height of our tile array
    int width = 0;
    int height = File.ReadLines(path).Count();

    StreamReader sReader = new StreamReader(path);
    string line = sReader.ReadLine();
    string[] tileNo = line.Split(',');

    width = tileNo.Count();
    mapLength = width * 40;
    // Creating a new instance of the tile Coin
    tileMap = new char[height, width];
    sReader.Close();

    // Re-initialising sReader
    sReader = new StreamReader(path);

    for (int y = 0; y < height; y++)
    {
        line = sReader.ReadLine();
        tileNo = line.Split(',');

        for (int x = 0; x < width; x++)
        {
            tileMap[y, x] = Convert.ToChar(tileNo[x]);
        }
    }
    sReader.Close();
}

0 个答案:

没有答案