2012-03-09 86 views
0

我得到上述錯誤,這阻止了我測試以查看我的相機是否工作。該代碼是:沒有合適的方法來覆蓋更新(GameTime gameTime)

protected override void Update(GameTime gameTime) 
{ 
    KeyboardState keyBoardState = Keyboard.GetState(); 

    //Rotate Cube along its Up Vector 
    if (keyBoardState.IsKeyDown(Keys.X)) 
    { 
     cubeWorld = Matrix.CreateFromAxisAngle(Vector3.Up, .02f) * cubeWorld; 
    } 
    if (keyBoardState.IsKeyDown(Keys.Z)) 
    { 
     cubeWorld = Matrix.CreateFromAxisAngle(Vector3.Up, -.02f) * cubeWorld; 
    } 

    //Move Cube Forward, Back, Left, and Right 
    if (keyBoardState.IsKeyDown(Keys.Up)) 
    { 
     cubeWorld *= Matrix.CreateTranslation(cubeWorld.Forward); 
    } 
    if (keyBoardState.IsKeyDown(Keys.Down)) 
    { 
     cubeWorld *= Matrix.CreateTranslation(cubeWorld.Backward); 
    } 
    if (keyBoardState.IsKeyDown(Keys.Left)) 
    { 
     cubeWorld *= Matrix.CreateTranslation(-cubeWorld.Right); 
    } 
    if (keyBoardState.IsKeyDown(Keys.Right)) 
    { 
     cubeWorld *= Matrix.CreateTranslation(cubeWorld.Right); 
    } 
} 

導致錯誤的行是:

protected override void Update(GameTime gameTime) 
+1

你確定你的基類有你想要覆蓋的方法? – ebutusov 2012-03-09 13:09:52

回答

0

你是不是從GameComponent繼承,你有兩個選擇:

  1. Inherite從GameComponent類:

    public class YourCameraClass : GameComponent { .... } 
    
  2. 在您的更新方法聲明中刪除「覆蓋」關鍵字:

    public void Update(Gametime gametime) {....} 
    
+0

我無法刪除保護,它會引發異常。 – user1259332 2012-03-12 10:05:50

+0

但添加只是GameComponent仍然會拋出相同的錯誤.... – user1259332 2012-03-12 10:08:56

+0

這可能是有關它是一個GraphicsDeviceControl而不是一個Microsoft.Xna.Framework.Game? – user1259332 2012-03-12 10:12:27

相關問題