Sign in to follow this  

Making the mouse disappear?

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites

This topic is 4717 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this