Making the mouse disappear?

Started by
3 comments, last by asafpolt 19 years, 3 months ago
I am currently writing a fps and I want to disappear the mouse. I was thinking of putting null in the Cursor property and keep moving it's location to the center of the form (I'm trying managed DirectX in C#). However, I'm hoping there's a better way to achieve it as this is very common to fps and other games too. Can't wait to your answers...
Advertisement
Can't you simply set the cursor to something completely transparant and be done with it? There's no need to start moving it.
---Yesterday is history, tomorrow is a mystery, today is a gift and that's why it's called the present.
If you're using C# then all you have to do is use

Cursor.Hide();

It's really that simple. If you're making a FPS game then, like you said, you'll also want to lock the cursor to the center of the screen (otherwise you'll hit a "wall" when you move too far to either side and the cursor thinks it's at the edge of the screen). To do this just set the cursor position to the center of the screen each frame using:

Cursor.Position = new Point(centerX, centerY);

then you can track movement of the mouse on a frame-by-frame basis -- ie. track how far the mouse has moved in that one frame and add that to the position rather than tracking absolute values. Hope that's what you're looking for.
Thanks, for some reason I was under the impression that the cursor.location is a read only property so I resorted to the Win32API function instead.

Guess I was wrong :)
Thanks, for some reason I was under the impression that the cursor.location is a read only property so I resorted to the Win32API function instead.

Guess I was wrong :)

This topic is closed to new replies.

Advertisement