So I always seem to get into wanting to build a game. I am 100% not the guy to do this stuff (game math blows my mind), but it never stops me from trying.
I have a simple problem right now: I am using XNA to run the game, and inside the UpdateInput method I am catching keystrokes to move the character around the screen.
When a character interacts with an NPC on my map, a modal dialog comes up using the Windows Form class. This dialog stops the user from clicking the mouse, as expected, but it still allows the UpdateInput method to catch keystrokes and move the character.
I am loading the dialog as such using a singleton pattern to ensure only 1 window can be open at a time.
And my UpdateInput method looks like thisCode:public void LoadDialog() { Dialog npcDialog = Dialog.Instance; npcDialog.Text = this.Name; npcDialog.setDialog(npcType); npcDialog.ShowDialog(); }//end Load
Now if it comes down to me detecting whether the class is active or not, I can handle that, but I had assumed a modal dialog would stop the parent form from receiving any input.Code:KeyboardState newState = Keyboard.GetState(); Keys[] keys = newState.GetPressedKeys(); if (!splashScreen && keys.Length > 0) { if (newState.IsKeyDown(Keys.Up) || newState.IsKeyDown(Keys.Down) || newState.IsKeyDown(Keys.Left) || newState.IsKeyDown(Keys.Right) || newState.IsKeyDown(Keys.W) || newState.IsKeyDown(Keys.A) || newState.IsKeyDown(Keys.S) || newState.IsKeyDown(Keys.D)) { mainCharacter.setSpriteDirection(1, keys[0].ToString()); } else if (newState.IsKeyDown(Keys.Escape)) { } else if (newState.IsKeyDown(Keys.Space)) { //interact with the environment mainCharacter.interact(); }//end if }


Reply With Quote