【发布时间】:2017-01-25 21:43:12
【问题描述】:
我刚刚开始使用 MonoGame,每当我运行我的程序时,我都会收到无法加载资产作为非内容文件错误。我一直在网上搜索,但没有找到任何关于我的问题的信息。请帮忙!
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace MoveDemo
{
public class MainGame : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D mainmenu;
public MainGame()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
mainmenu = Content.Load<Texture2D>("MainMenu");
}
protected override void UnloadContent()
{
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
spriteBatch.Begin();
spriteBatch.Draw(mainmenu, new Rectangle(0, 0, 840, 480), Color.White );
spriteBatch.End();
base.Draw(gameTime);
}
}
}
【问题讨论】:
-
我假设您已经通过内容管道工具添加了文件并且它已构建?