XNA Framework进口商 [英] XNA Framework Importers

查看:100
本文介绍了XNA Framework进口商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用XNA框架开发游戏.我的游戏有多个级别,我将数据存储在一个普通的旧文本文件中.在VS 2008中,将级别文件添加到项目中并进行编译时,收到以下错误消息.

I am working on a game using the XNA framework. My game has several levels which I am storing the data in a plain old text file. In VS 2008 when I add the level file to the project and compile, I receive the following error message.

错误1无法自动检测要用于"Levels \ 0.txt"的导入器.没有导入程序可以处理此文件类型.指定在项目中处理此文件类型的导入器. F:\ Projects \ BrickBreaker \ BrickBreaker \ Content \ Levels \ 0.txt BrickBreaker

Error 1 Cannot autodetect which importer to use for "Levels\0.txt". There are no importers which handle this file type. Specify the importer that handles this file type in your project. F:\Projects\BrickBreaker\BrickBreaker\Content\Levels\0.txt BrickBreaker

之所以要这样做,是因为如果我改变关卡并运行游戏,则关卡不会更新.我发现该级别未更新,因为VS从bin \ debug文件夹运行游戏,并且由于该级别文件未包含在项目中,因此更改时不会复制它们.我还发现,框架随附的平台示例在项目中包含了关卡数据,这就是我从中获得技术的地方.

The reason I am bringing this out is because if I change on of my levels and run the game, the level is not updated. I have found that the level is not updated because VS runs the game from the bin\debug folder and since the level files are not included in the project, they are not copied when they change. I also found that the platform sample that comes with the framework includes the level data in the project, that's where I got the technique from.

所以,我应该使用其他文件格式还是只需要手动复制新关卡文件?

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

解决方案-在研究了这篇文章的答案后,我找到了解决方案.我将文本文件添加到项目中,并将build属性设置为none.编译时不再发生该错误,并且文件已包含在项目中.

Resolution - After digging into the answers on this post I found a solution. I added the text files to the project and set the build property to none. The error no longer occurs when compiling and the file is included in the project.

推荐答案

如果您想将Visual Studio复制到输出目录,则可以使Visual Studio复制这些文件.在项目中文本文件的属性下,选择构建操作:无",然后根据需要将副本更改为输出目录.

You can have Visual Studio just copy over the files if you want to the output directory. Under the properties of the text file in the project, choose Build Action: None and change the copy to output directory to as needed.

您也可以签出平台游戏样本.他们使用文本文件作为其级别格式.

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

这篇关于XNA Framework进口商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆