I'm trying to create a 2D array in XNA which I'll be using as a tile map for a game I'm working on. I've read various solutions but none of them seem to be working for me. One of the main issues I'm having is an error:
Cannot autodetect which importer to use for "map.txt". There are no importers which handle this file type. Specify the importer that handles this file type in your project.
This appears to be caused by the StreamReader class that I'm attempting to use.
I'm using XNA 4.0.
My .txt file looks like this (example):
0,0,0,0,0
0,0,0,0,0
0,0,1,0,0
0,1,1,1,0
1,1,1,1,1
My C# and XNA looks like this:
string line = string.Empty;
using (StreamReader sr = new StreamReader("5x5-map"))
{
while ((line = sr.ReadLine()) != null)
{
//reads line by line until eof
//do whatever you want with the text
}
}
If anyone could help me, or point me in the direction of a working example that would be great.