Disabling/freezing controllers

If I wanted to freeze a controller but still render its last view in the background whilst I used my GUI what would be the best approach?

I’ve tried reducing the setMovementSpeed() method parameter to zero at the relevant point just before I render my GUI, but this seems to have no effect.

It seems my controller & GUI pointer are sharing the same events, but it would be a step forward if I could freeze the controller & still render the world even if GUI pointer was frozen.


Try not updating the controller when you don’t want to use it…


in your app:

//was this
update() {
   if(!controller.update(timer.getFrameRate()) {

make something like:

update() {
   if(playMode) {
      if(!controller.update(timer.getFrameRate()) {
   } else if(guiMode) {
      //use other controller.

That *should* work.

Thanks, :slight_smile:

Got it partially working now.

Just need to find the right place to set it to go back to the controller after the GUI has cleared - but I’m nearly there now.

Like the approach and it seems to work (in my trivial test). What I am not sure is where to put the logic i.e. check if the user has pressed the key or not. In 2D is fairly straight forward as it would be in the event handling code. Any suggestions?


What about setting a key to switch the playMode flag to false and the guiMode flag to true (say esc).

So that would put you in gui mode, then have a gui button that switches the playMode flag to true and the guiMode flag to false (say "Resume").

I set 2 booleans as globals & then initialised them when I pressed ESC to bring up the GUI.

in the render method() I said:

//only allow GUI to appear when ESCape is pressed
      if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
            playMode = false;
            guiMode = true;

w is the spag window set up else where

I think you still need to detect the key press somewhere so may be some code in the update() to check if a key has been pressed (we do this by calling say a status method for the xxxListener for that key).

I have done this in the update method and seems to work.


Do you mean if we add a meessagebox listener to the message box & then reset to playmode once we have clicked on OK?

I think this should work.

Well, keep the test/playing coming. Right now I am working on the new input handling system, and will involve some controller ideas. So, now is the time to make changes to allow for easy switching.