我通常会在XNA论坛上寻求帮助,但目前该论坛已关闭,所以我来到这里。
我正在制作一个新的XNA游戏,并想要创建一个玩家类。目前我有一个名为Dots
的主游戏类,它代表了整个游戏。以下是我目前的Player
类的布局:
namespace Dots
{
class Player : Microsoft.Xna.Framework.Game
{
Texture2D PlayerTexture;
Vector2 PlayerPosition;
public Player()
{
Content.RootDirectory = "Content";
PlayerTexture = Content.Load<Texture2D>("Player");
PlayerPosition = Vector2.Zero;
}
public void Update()
{
}
public void Draw(SpriteBatch SpriteBatch)
{
}
}
}
但是我遇到了一个错误,我不知道该如何解决。错误信息如下:
它在这一行代码抛出的:加载"Player"时出错。找不到GraphicsDevice组件。
PlayerTexture = Content.Load<Texture2D>("Player");
。我在主游戏类中看到这一行代码:
Graphics = new GraphicsDeviceManager(this);
,但我不知道该怎么做。我应该将它传递给我的Player
类吗?非常感谢您的帮助。