public HandleInput ( FarseerPhysics.ScreenSystem.InputState input ) : void | ||
input | FarseerPhysics.ScreenSystem.InputState | |
return | void |
public virtual void HandleInput(InputState input)
{
//Keyboard Input
if (!input.LastKeyboardState.IsKeyDown(Key.F1) && input.CurrentKeyboardState.IsKeyDown(Key.F1))
{
DebugViewEnabled = !DebugViewEnabled;
if (DebugViewEnabled == false)
TxtDebug.Text = "";
}
if (!input.LastKeyboardState.IsKeyDown(Key.Escape) && input.CurrentKeyboardState.IsKeyDown(Key.Escape))
{
ScreenManager.GoToMainMenu();
}
//Mouse
Point p = Transform.Inverse.Transform(new Point(input.CurrentMouseState.X, input.CurrentMouseState.Y));
Vector2 position = new Vector2((float)p.X, (float)p.Y);
if (input.CurrentMouseState.IsLeftButtonDown == false && input.LastMouseState.IsLeftButtonDown)
{
MouseUp();
}
else if (input.CurrentMouseState.IsLeftButtonDown && input.LastMouseState.IsLeftButtonDown == false)
{
MouseDown(position);
}
MouseMove(position);
//DebugView
if (DebugView != null)
{
if (DebugViewEnabled)
DebugView.AppendFlags(DebugViewFlags.DebugPanel);
else
DebugView.RemoveFlags(DebugViewFlags.DebugPanel);
}
}
/// <summary> /// Allows each screen to run logic. /// </summary> public override void Update(GameTime gameTime) { // Make a copy of the master screen list, to avoid confusion if // the process of updating one screen adds or removes others. _screensToUpdate.Clear(); for (int i = 0; i < _screens.Count; i++) { _screensToUpdate.Add(_screens[i]); } bool otherScreenHasFocus = !Game.IsActive; bool coveredByOtherScreen = false; // Loop as long as there are _screens waiting to be updated. while (_screensToUpdate.Count > 0) { // Pop the topmost screen off the waiting list. GameScreen screen = _screensToUpdate[_screensToUpdate.Count - 1]; _screensToUpdate.RemoveAt(_screensToUpdate.Count - 1); // Update the screen. screen.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen); if (screen.ScreenState == ScreenState.TransitionOn || screen.ScreenState == ScreenState.Active) { // If this is the first active screen we came across, // give it a chance to handle _input. if (!otherScreenHasFocus) { screen.HandleInput(_input); otherScreenHasFocus = true; } // If this is an active non-popup, inform any subsequent // _screens that they are covered by it. if (!screen.IsPopup) { coveredByOtherScreen = true; } } } //Process Input _input.Update(gameTime); }