I'm a little lost with how to manage input within the gamestate framework. Also, I am unsure that I am using the gamestates properly; so plese chime in if what I am doing is incorrect. This is what I am doing:
- in my Game1.cs I create a GameStateManager and a few subclasses off GameState (StartGameState, LevelGameState, EndGameState). In Initialise() I create an InputManager and setup a delegate to listen for keyPressed events. In LoadContent() I
instantiate StartGameState and push it on the GameStateManager. note: I call update for the InputManager and GameStateManager in Update(); and call draw for the GameStateManager in Draw().
- StartGameState implements IDrawable. Does it matter if I set the DrawOrder to always return 0; and Visible to always return true? I don't know how to implement IDrawable properly and I have not yet found a tutorial which explains it in a way
I can fully understand; especially within the context of Nuclex's GameStateManager.
- in StartGameState I store a reference to the InputManager. I use this to setup a delegate to listen for keyPressed events.
What happens is I get both the Game1.cs and StartGameState delegates being called when a key is pressed. What I want is for input handling to go with the GameState; just like the updating and drawing does.
I think I need to stop using events and handle input by hand in the Update menthod instead. Is this the way everyone else is doing it?