I have two different modes in my game and one inputManager with a lot of keyinputs registered. I was wondering what is the best way to disable some keys in one mode and re-enable them back in another mode.
So for example if I have the keyboard arrows that control the camera, I want to disable them with a single button, and be able to reenable them back with a different button.
I hope this makes sense. Although it sounds simple, I cannot figure it out.
hey guys sorry I didn’t get any notifications about your replies. I am very familiar with AppStates and that would be definitely the cleanest desisn but I previously used appStates for things such as bakcground calculations, timer, etc I have never used it with inputManager. I am not asking to show me a pseudocode or anything, just can you elaborate more in a few lines how would I use AppStates in order to have two versions of inputManager mappings?
Well, having the mapping is not enough. You also need a listener added somewhere. Maybe the camera is not doing this right or they get cleared at some point because the mappings are removed or something. I cannot really say. Normally it works.
update: more debugging on the code onAction gets called and does exactly the same thing before the map clearing
[java]
public void onAction(String name, boolean value, float tpf) {
if (!enabled)
return;
if (name.equals("FLYCAM_RotateDrag") && dragToRotate){
canRotate = value;
inputManager.setCursorVisible(!value);
}
}
[/java]
So the only thing not happening is that the mouse is not dragging to rotate. I am really confused why the cam isn’t moving. I also notice the mouse scroll wheel isn’t working as well.
so in summary, if I clear the inputManager using clearMappings() , how can I get the mouse to work again???
can someone at least explain to me how does it work? Looking at FlyByCamera.java there’s a method for every keyinput or mouse input (e.g. A, S, Left Button, ) to move, zoom, or do whatever with the camera - GOOD! But how about the DragToRotate() how is that handled?? I tried to debug it and got really confused. esepcially about this part:
[java]
public void onAction(String name, boolean value, float tpf) {
if (!enabled)
return;
if (name.equals("FLYCAM_RotateDrag") && dragToRotate){
canRotate = value;
inputManager.setCursorVisible(!value);
}
}
[/java]
as I am getting the same exact value before and after I clear and re-assign the mappings but no luck.
In summary, can someone please tell me if I cleared the mappings of the input manager how can I add back the mouse controls (mainly the drag to rotate)? I was able to add it for all the other keys but no luck with the mouse control… I have been stuck on that for more than 2 weeks of non stop trials…
Sorry if I’m not helping you a lot, but dragging is really hard because there’s not support for it.
If fact, it’s divided in several independent steps :
mouse-down
mouse-move
mouse-up
I would have to check the whole code to give you better insight. The fragment you gave is not sufficient.
No more time now, but I will this evening…