无法将单游戏 (xna) 库导入我的新项目



我想第一次开始使用Monogame,并且在遵循了关于如何在网站上安装的教程之后。我似乎根本无法访问库,它在Game基类中根本找不到任何数据。

错误消息:

"错误CS0234命名空间"Microsoft"中不存在类型或命名空间名称"Xna"(是否缺少程序集引用?("Pong C:\Users\danie\source\repos\Pong\Pong\Game1.cs 1活动

关于为什么会出现此错误的任何想法,我都使用.NET 6。据我所知,我有最新消息。

我还安装了Visual Studio中的所有东西(.NET桌面开发工具和跨平台工具等(,但我仍然无法找到库。


using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace Pong
{
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
base.Draw(gameTime);
}
}
}

运行一次项目。我建议使用一个空项目进行缓存加载。这些错误应该会消失。

该技术还解决了MGCB编辑器不加载到新用户配置文件上的问题。

nuget缓存是针对每个用户配置文件的。项目的依赖项只有在第一次运行时才下载和加载,如果还没有,则通过运行项目。

最新更新