Disable mouse / keyboard move in SimpleGame

when i extends SimpleGame, the default is mouse and keyboard can control the camera moving.  Anyway to disable any of the movement?



I only want fixed position of objects.

You don't use SimpleGame, you switch to either BaseGame or StandardGame.

because the code is developed on extends SimpleGame, if I use BaseGame, I will need to change alot of code i guess.



any other ways to disable the mouse / keyboard events in SimpleGame?

Copy and paste SimpleGame into your own package, rename it to something else and remove the input related code.  Just change your game to extend the modified simple game and you are good to go.



Alternatively you could edit SimpleGame itself, but then you would have issues when updating from cvs.

so there’s no way to disable the mouse from SImpleGame???

Not if you use jME2 no xD Dude, this thread is 4 years old. jME3: flyCam.setEnabled(false);

OUps !!! my bad lol



btw flyCam.setEnabled(false); only disable the flyCam (ASDW and arrows) my mouse is still working fine.

[java]inputManager.clearMappings();[/java]

But this is very agressive.



There’s apparently no way to disable it, the update of inputManager is done in Application.update() which you can’t bypass easily.

we can’t just disable the mouse w/o clearing everything? I need the keyboard to be functional :S



thats’ weird, isn’t it supposed to be an easy feature?

Try this ?

[java]inputManager.deleteMapping("FLYCAM_Left");

inputManager.deleteMapping("FLYCAM_Right");

inputManager.deleteMapping("FLYCAM_Up");

inputManager.deleteMapping("FLYCAM_Down");

inputManager.deleteMapping("FLYCAM_ZoomIn");

inputManager.deleteMapping("FLYCAM_ZoomOut");



inputManager.setCursorVisible( true );[/java]

1 Like

Great!!! works like a charm!!! disabled the keyboard arrows too but I can live with that.



thx!!

one more thing and again THANKS for the great help but how can I trigger a function when someone clicks outside the window frame of Jme?



I want to initiate a function (say pause() or anything) whenever the user clicks outside by mistake.

In your SimpleApplication implementation :

[java]

@Override

public void gainFocus()

{

super.gainFocus();

if ( !pauseOnFocus ) inputEnabled = true;

}





@Override

public void loseFocus()

{

super.loseFocus();

if ( !pauseOnFocus ) inputEnabled = false;

}

[/java]

gainFocus() happens when the user activates your program ; loseFocus when he clicks somewhere outside the window.

I also added a “if” to disable inputs when you’re out-focus.

1 Like

you’re the man!!!

The error seems quite clear, you are trying to clear a non existing mapping, so either it has already been cleared or you have the wrong name for the mapping.

Try to navigate to the FlyByCamera class in FlyByCamera.java in the source code. In my version, which is the latest stable, these mappings are listed:

String[] mappings = new String[]{

“FLYCAM_Left”,

“FLYCAM_Right”,

“FLYCAM_Up”,

“FLYCAM_Down”,



“FLYCAM_StrafeLeft”,

“FLYCAM_StrafeRight”,

“FLYCAM_Forward”,

“FLYCAM_Backward”,



“FLYCAM_ZoomIn”,

“FLYCAM_ZoomOut”,

“FLYCAM_RotateDrag”,



“FLYCAM_Rise”,

“FLYCAM_Lower”

};

well my function is there so obviously I am not typing it wrong and it was working before so it’s not that. Also, I haven’t cleared it anywhere else. This is the only function that deals with inputManager.

Also I am using the LATEST version (actually the build a few nights ago) and not latest STABLE version. Is there a difference?

yeah, nightly might be randomly broken

so how can I get a stable version? I am not assuming by trial and error right?



sorry if my question is silly but I am new at all this.



thankx

:? If you use the SDK you simply don’t tick the nightly update center, if you use svn you use branches/3.0beta