c# - 编译器错误1 : constructor contains more than 0 args

标签 c# visual-studio-2010 compiler-errors xna-4.0

我是C,C#,XNA的初学者,并且尝试在线学习一些教程,但是当我尝试从其他类中创建桨状对象时,出现错误,即构造函数不包含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);
}

这是我的桨类(class)的开始
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();的地方

关于c# - 编译器错误1 : constructor contains more than 0 args,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14488832/

相关文章:

c++ - 为什么这段代码会使 VC++ 编译器崩溃?

visual-studio-2010 - 有没有像 CodeRush 这样的免费 Visual Studio 扩展 "drops markers"

python-3.x - 尽管 xxx 是全局定义的,但预期的 NameError : name 'xxx' is not defined

windows - 如何在 QtCreator 中设置编译器和调试器

c# - 无法从 Windows 窗体应用程序中的 app.config 连接到本地 SQL 数据库

c# - 将数据绑定(bind)到 Asp.net 中的模板字段

visual-studio - 如何在 Visual Studio 2010 中执行 "shell"图标嵌入?

c++ - 嵌套结构初始化

c# - Dapper具体化为元组

时间:2019-03-17 标签:c#SetupProjectLocalization