Anna
Anna

Reputation: 571

I don't have a GetState() method for KeyboardState?

SO I am working on input handling, I assumed this should be SIMPLE but the problem right now is I don't even have a getstate() method??? REALLY? Somebody knows how to fix this??

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Game1
{
public class Keyboard:IController
{
    public void UpdateInput()
    {
        KeyboardState newState = Keyboard.GetState();

        if (newState.IsKeyDown(Keys.Q))
        {

        }
    }
}
}

That's ALL my code I swear, nothing else. The Error is, Keyboard does not contain a definition for GetState()

Upvotes: 1

Views: 496

Answers (1)

Ilian
Ilian

Reputation: 5355

The compiler sees Keyboard.GetState() and assumes you mean the class you defined:

public class Keyboard:IController

Either, fully qualify Keyboard to:

Microsoft.Xna.Framework.Input.Keyboard.GetState()

or, rename your class to something else, like:

public class KeyboardController : IController

Upvotes: 2

Related Questions