setCursorVisible doesn't work

Hi,

I have this problem. I am using assetManager.setCursorVisible(true) in my game, but it doesn’t work at all. Game just starts and cursor is hidden.

I also tried use assetManager.removeListener(flyCam), but it doesn’t help.

I tried use this in simple program HelloAnimation from tutorials and it doesn’t work there niether. I’m using jMonkeyEngine SDK 3.0beta.

I’m new to jMonkeyEngine, so please can you tell what am I doing wrong or where can be the problem??



(Also sorry for my poor English)



Thanks

another Flycam Appstate issue :slight_smile:



Its not ideal, but there are a few ways you can bypass this.



#1 - Remove the flycam appstate (either in simple init, or by passing null to the super() constructor to your derived SimpleApplication class

#2 - Set [java]assetManager.setCursorVisible (true); [/java] after simpleInitApp, perhaps in the update loop. You can create a control/appstate, which call it, then removes the control/appstate itself, so u don’t waste the unnecessary condition statements every frame

bageta said:
I tried use this in simple program HelloAnimation from tutorials and it doesn't work there niether. I'm using jMonkeyEngine SDK 3.0beta


Just so you know, beta is no longer updated, you can install RC2.
@wezrule said:
another Flycam Appstate issue :)

Its not ideal, but there are a few ways you can bypass this.

#1 - Remove the flycam appstate (either in simple init, or by passing null to the super() constructor to your derived SimpleApplication class
#2 - Set [java]assetManager.setCursorVisible (true); [/java] after simpleInitApp, perhaps in the update loop. You can create a control/appstate, which call it, then removes the control/appstate itself, so u don't waste the unnecessary condition statements every frame

...or... everything you do in simpleInitApp and simpleUpdate... do in an app state and leave those methods empty.

But if you don't want fly cam... remove fly cam as suggested. Though, do not pass null to the super()... just don't pass anything and you will get none of the default app states.

FlyCam is initialized by an app state. App states aren't initialized until after simpleInitApp. I guess this is because simpleInitApp is designed to do things before the app states run. FlyCam will setCursorVisible(false) when it is initialized after simpleInit.

Also, I think everywhere in this thread where you guys had assetManager is really supposed to be inputManager.

Ok,

it works. Thanks.

I have created an own app state and tried to call it in the initialize(…) method of my app state, but it did not work. Even doing it once in the update loop does not work:

@Override
public void update(float tpf) {
	super.update(tpf);
	if (firstUpdate) {
		firstUpdate = false;
		// TODO has this realy to be done in the update method to work?
		app.getInputManager().setCursorVisible(true);
	}
}

only if I do it in every update call it works like expected. Do I have to set something else in addition to setCursorVisible() ?

@simon.heinen said: I have created an own app state and tried to call it in the initialize(..) method of my app state, but it did not work. Even doing it once in the update loop does not work:
@Override
public void update(float tpf) {
	super.update(tpf);
	if (firstUpdate) {
		firstUpdate = false;
		// TODO has this realy to be done in the update method to work?
		app.getInputManager().setCursorVisible(true);
	}
}

only if I do it in every update call it works like expected. Do I have to set something else in addition to setCursorVisible() ?

You only have to call it once unless something else is calling it. Maybe you haven’t removed the FlyCamAppState?

I bet if you call it only on the second frame that it might work. Really you just need to get your app states straightened out. Otherwise we haven’t been given enough information to help.

Also… you said "and tried to call it in the initialize(…) " NEVER ever ever ever, and I mean NEVER call initialize yourself. That indicates that you are doing something very wrong. Attach the state to the state manager and its initialize() and update() methods are called automatically.

<cite>@pspeed said:</cite> You only have to call it once unless something else is calling it. Maybe you haven't removed the FlyCamAppState?

I want to use the flyCamAppState like it is with wasd controls etc but I only want the camera to rotate when the left (or even better right) mouse button is pressed.

<cite>@pspeed said:</cite> Also... you said "and tried to call it in the initialize(..) " NEVER ever ever ever, and I mean NEVER call initialize yourself. That indicates that you are doing something very wrong. Attach the state to the state manager and its initialize() and update() methods are called automatically.

i ment that i added it to the initialize method of my app state (and im still calling super.initialize(stateManager, app) :wink:

@simon.heinen said: I want to use the flyCamAppState like it is with wasd controls etc but I only want the camera to rotate when the left (or even better right) mouse button is pressed.

If you set drag to rotate true then it shouldn’t be turning the cursor off.