Jump to content
  • Advertisement
Sign in to follow this  
asafpolt

Making the mouse disappear?

This topic is 4935 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
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.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!