Custom Cursor

Hello,



I’m new to programming in Java and espacially in JME. I have a problem with the cursor: it leaves the window if I enable it. I’ve read in this forum that I should use my custom cursor, and I found some tutorials about this. But there was one line I couldn’t use. It was

setCursor(cursor);

I just need an object which I attach the cursor to. And that’s my question. Which object is it?



Sincerely, Armin



PS: Sorry for my bad English, but I’m from Germany.

Well I use the cursor class from lwjgl directly. I suggest to look a few pages back in the forum, there was a post about cursors (and some code snippets), I think it was from madjack, but not sure.

@marelsmudda said:
I have a problem with the cursor: it leaves the window if I enable it.

Know that this is really bad form. The cursor should not be constrained inside a window unless you have an extremely good reason. So far I've never heard of a good reason to do this.


I've read in this forum that I should use my custom cursor, and I found some tutorials about this. But there was one line I couldn't use. It was
setCursor(cursor);
I just need an object which I attach the cursor to. And that's my question. Which object is it?

Changing the cursor wouldn't change its constraint.

The only way you can constraint the cursor is by doing it yourself. You verify the location of the mouse cursor and if it's out of the game window's size you "move it back" inside. Even then, I'm not sure you can force that without modifying jME3's code or extending the class. Either, it's still bad form.
@madjack said:
So far I've never heard of a good reason to do this.

cause RTS in a window sucks when the mouse goes out all the time ^^
1 Like
@madjack said:
Know that this is really bad form. The cursor should not be constrained inside a window unless you have an extremely good reason. So far I've never heard of a good reason to do this.


there is a simple and also good reason. I'm trying to program a RTS-game and I want the cursor to move the camera as it is touching the edge of the window.
1 Like

Hehe, mind reading abilities intact: check. ^^

@normen @marelsmudda



Make you game fullscreen then. Problem solved. When I put my games in windowed mode I expect to have the mouse go out the window (because that’s the normal and expected behavior). I would hate a game that constrained my mouse when I want to do something else while it runs.



If anyone has a RTS like StarCraft 2, run it windowed and tell me they constrained the cursor. I’d bet a lot of $ it’s not.

It is and I frequently played games like e.g. WoW in windows so I can see other tools, Teamspeak clients etc. etc. Or just plain being at work :stuck_out_tongue:

@normen said:
It is and I frequently played games like e.g. WoW in windows so I can see other tools, Teamspeak clients etc. etc. Or just plain being at work :P


Not sure I understand. Are you saying WoW constrain the mouse in windowed mode? Cause I played WoW and my mouse was NEVER constrained. Maybe it's an option?
@madjack said:
Not sure I understand. Are you saying WoW constrain the mouse in windowed mode? Cause I played WoW and my mouse was NEVER constrained. Maybe it's an option?

Or its different on macs where you cannot switch out of a fullscreen game while keeping it running, I don't remember.

Mouse cursor is (most of the time) constrained in fullscreen mode. That’s the expected behavior. I have played games where, because I have multiple monitors, the cursor would end up in the second monitor, so that would minimize the game. Infuriating. But those are rare. When I find out I have a game like that I put it in windowed mode. It’s much easier to go back to the game that way.



Fullscreen = mouse constrained.

Windowed = free mouse.



That’s the “standard”.

More like that “should be the standart”. I gues i could give you a list of hunderets of games that do not behave like that.

@EmpirePhoenix said:
More like that "should be the standart". I gues i could give you a list of hunderets of games that do not behave like that.


Please do. I haven't seen many real games that acted that way. Yes, some do, but they are rare.

As long as it is easy to leave the window with the cursor by pressing Esc for example, I wouldn’t mind if it’s not common to catch it in windowed mode or not. I wrote a game in December’s Ludum Dare where you clicked into the window to tell your character to move into the direction of the cursor. If I hadn’t used java.awt.robot, the cursor would have been outside the window very often due to the neccessary fast reactions. And you don’t want such a small game to be fullscreen.

Well almost all games older than 2000 have problems with multimonitor.

More recent Diablo 3 for some reason insits on my taskbar to be infront of the game, so I have to use windowd if I dontw ant to start random programs while playing…

For games when the mouse is capture because it’s used as a direction like in FPS, that’s fine. The mouse should remain within the constraints of the window. But, for games where the mouse is free, it should not be constrained into the window.



I’m not against a toggable setting to enable constrain at all times, but it shouldn’t be the default.