我开始学习“一些” XNA 并且 - 正如预期的那样 - 我很早就遇到了障碍。
- 我创建了一个 WP7 XNA 游戏解决方案
- 我已删除默认内容项目
- 我添加了自己的内容项目“Sprites”
- 我已将 3x *.png 文件添加到“Sprites”项目(MyImage1.png、MyImage2.png、MyImage3.png)
- 我添加了一个内容引用,将“Sprites”引用到主游戏项目
/**/
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
logoTexture = Content.Load<Texture2D>("Sprites/MyImage1");
// TODO: use this.Content to load your game content here
}
尝试加载我的 *.png 文件时,我收到 ContentLoadException 说“未找到”
- 我确实检查了输出目录,存在一个包含 *.xnb 文件的“Sprites”子文件夹
- 我确实检查了图像的属性,所有图像都标记为 Texture2Ds,并且内容导入器和处理器设置为默认 XNA 值
我很确定我犯了一个常见的 n00b'ish 错误,但我没有看到它,所以我希望得到一些指导。
问题已修复
Content.RootDirectory = "Content"; // The cause of the problem
问候