XNA Framework Importers

I am working on a game using the XNA infrastructure. There are several levels in my game that I store in a plain text file. In VS 2008, when I add a level file to the project and compile, the following error message appears.

Error 1: It is not possible to automatically determine which importer to use for "Levels \ 0.txt". Importers that process this type of file do not exist. Specify the importer who processes this type of file in your project. F: \ Projects \ BrickBreaker \ BrickBreaker \ Content \ Levels \ 0.txt BrickBreaker

The reason I do this is because if I change my levels and start the game, the level will not be updated. I found that the level is not updated, because VS launches the game from the bin \ debug folder, and since the level files are not included in the project, they are not copied when they are changed. I also found that the sample platform that comes with the framework includes level data in the project where I received the equipment.

So, should you use a different file format or just deal with the need to manually copy files to a new level?

Resolution. After I read the answers to this post, I found a solution. I added text files to the project and set the build property to none. The error does not occur during compilation, and the file is included in the project.

+4
source share
3 answers

You can have Visual Studio just copy the files if you want the output directory. In the properties of the text file in the project, select "Create action": "No" and, if necessary, change the copy to the output directory.

You can also check out the sample platform. They use text files as their format.

+8
source

Text files do not have a content importer. Ignore the content pipeline and just read the file just like any other plain text file.

string line = string.empty; using(StreamReader sr = new StreamReader("filename")){ while((line = sr.ReadLine()) != null){ //reads line by line until eof //do whatever you want with the text } } 
+2
source

I had a similar problem and it was easier for me to add files to the content project and set the action to none than skip the content pipeline altogether.

0
source

All Articles