private void switchState(GameState newState) { if (currentState != null) { currentState.dispose(); } currentState = newState; LoggingContext.setGameState(newState); newState.init(this); for (StateChangeSubscriber subscriber : stateChangeSubscribers) { subscriber.onStateChange(); } // drain input queues InputSystem inputSystem = rootContext.get(InputSystem.class); inputSystem.getMouseDevice().getInputQueue(); inputSystem.getKeyboard().getInputQueue(); }