2013-01-23 34 views
0

我是C,C#,XNA的初學者,我試圖在線學習一些教程,但是當我嘗試從不同的類製作槳對象時,構造函數不包含0參數的錯誤。我不知道錯誤是在我的遊戲課還是在我的槳板課上。編譯器錯誤1:構造函數包含多於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

由於開始提前爲任何幫助你可以給!

+0

只是一個評論。 「槳槳」不會「創建槳」。它*聲明*槳。 'paddle = ...'創建槳。 –

+1

編譯器錯誤應該說錯誤位於哪個文件的哪一行。 – itsme86

回答

0

某處你說的paddle = new Paddle();

+0

WOW!我不小心將舊代碼混入了創建錯誤的新東西中。只要我刪除這一行,就會有50個出現。謝謝! – user2005078

相關問題