我是 C、C#、xna 的初学者,我正在尝试在线学习一些教程,但是当我尝试从不同的类制作一个 paddle 对象时,我收到构造函数不包含 0 个参数的错误。我不知道错误是在我的游戏类还是我的桨类中。
我的游戏课上的重要代码:
Paddle paddle; // creates a paddle
...
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
screenRectangle = new Rectangle(
0,
0,
graphics.PreferredBackBufferWidth,
graphics.PreferredBackBufferHeight);
}
...
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
Texture2D tempTexture = Content.Load<Texture2D>("paddle");
paddle = new Paddle(tempTexture, screenRectangle);
}
这是我桨课的开始
public class Paddle : Microsoft.Xna.Framework.GameComponent
{
Vector2 position;
Vector2 motion;
float paddleSpeed = 8f;
KeyboardState keyboardState;
GamePadState gamePadState;
Texture2D texture;
Rectangle screenBounds;
public Paddle(Texture2D texture, Rectangle screenBounds)
{
this.texture = texture;
this.screenBounds = screenBounds;
SetInStartPosition();
}
我正在按照教程进行操作 http://xnagpa.net/xna4/beginnertuts/BreakingOut1.pdf
提前感谢您提供的任何帮助!
你在某处说paddle = new Paddle();