我对 XNA 很陌生,我从遵循在屏幕上绘制图像的教程开始。我能够将我的图像移动到 Content 文件夹中,但是当我尝试在我的代码中使用它时,找不到它。
我正在使用资产名称,但我找不到我做错了什么。教程使用 XNA 3.0,我使用 Visual Studio 2010,不确定这是否重要。
这是我的代码
public class Game1 : Microsoft.Xna.Framework.Game
{
Vector2 mPosition = new Vector2(0, 0);
Texture2D mSpriteTexture;
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
mSpriteTexture = Content.Load<Texture2D>("Face");
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Draw(mSpriteTexture, mPosition, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
错误显示“ContentLoadException 未处理。找不到文件。
我希望这是足够的信息。我的文件的资产名称也是人脸。
提前致谢。