Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am trying to make an InputManager class that will let me basically bridge XNA's various input methods and do a corresponding action in my game. Part of this is designing different keybindings.

Suppose I have a class GamePadBinding : InputBinding<Button> - this is the Button enum from XNA.Input and has a variety of different buttons (Left, A, etc). However, to actually check input, I have to call something like if (GamePad.GetState(PlayerIndex.One).DPad.Left == ButtonState.Pressed), and the problem with that is that it uses a struct with readonly values.

How am I expected to store an enum of type Button and compare that with this? I really am not seeing the point of this enum.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

You can check the button state easier using the GamePadState.IsButtonUp and GamePadState.IsButtonDown methods. These both accept an Input.Buttons parameter.

See the MSDN article.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.