Controller and setActive(boolean)

Hey guys.



Is there any reason that the active-flag is not used by the implementations of Controller (ActionController, ActionRepeatController)?

This is rather confusing, since the setActive-method appears in the public interface and sould be assumed to work.

no good reason, at least :wink:

That is a problem of interfaces I guess, you can't really enforce those rules on all implementations.

Maybe this should be done on the calling side? i.e the code which executes the update method of the controllers.

Momoko_Fan said:

Maybe this should be done on the calling side? i.e the code which executes the update method of the controllers.


This could be a possibility but it somehow contradicts the consistency of the engine. Calling setActive on GameStates and setCollidable on scene elements etc. also has the expected effect, as far as the game loops, collision results and all the other jME stuff is concerned.

I'm rather iterested in how it actually was planned. I suppose, darkfrog is the author... Maybe he can tell us more?

No, I can't take the blameā€¦err, I mean credit for GameStates. :o  They've existed long before I was newbie on here.  However, I might be partially to blame for the notoriety they've achieved in the past couple of years. :wink:



I've noticed the issues you've stated on Controllersā€¦the problem seems to be in design scope of whether the system calling update on the Controller should check to see if it's enabled before calling it, or whether the update method itself should check to see if it is enabled before doing any work.  This has been something of a frustration point for me in the past as well and though I think I've cleaned up several of the controllers that I was utilizing at the time, I know there are several others that really need to be updated.

I was actually trying to implement something like a controller cycle that itself implements controller and forwards the update-call to the active controller in the cycle.

Pressing a specified game control would select the next controller in the cycle.



The idea is having different (cycleable) action bound to one GameControl easily.

But the thing I have trouble with is for example the absolutely different implementations of ActionController and ActionRepeatController. It does not allow you to handle controllers uniformly. ActionConctoller absolutely needs to call released on the GameControlAction when switched off, while ActionRepeatController doesn't event utilize GameControlAction.

That gives me a really hard time composing Controller nodes.



I got to the setActive-fug (fug = feature/bug) when I tried to achieve the desired effect and it somehow got me unprepared that after setActive(false) on a Controller the Controller actually would continue to update.



Anyway, is there something I should be doing differently? All my software engineering knowledge tells me something is wrong there! :wink:

I will probably end up implementing my own Controllers, but it would be really nice to have consistent behaviour of jME.