Sign in to follow this  

[.net] XNA mouse cursor

This topic is 3776 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

Is there a way with XNA we can hide the mouse cursor from appearing outside the window in windowed mode? I can't find anything about it in the XNA docs. Maybe I overlooked it? -SirKnight

Share this post


Link to post
Share on other sites
All my XNA projects hides the mouse cursor by default in windowed mode.

Try creating a new Windows Game project and run it straight away.

Does it hide the mouse cursor?

Share this post


Link to post
Share on other sites
This should be seen as bad practice; consider this case.

I am playing your windowed game and suddenly an IM window pops up in the background. Nothing out of the ordinary except for the fact that I wish to click it. I am no stuck in guessing where the mouse cursor is.

Although this is possible by using the Win API, please do not do it.

Share this post


Link to post
Share on other sites
I have not looked at any thing with XNA, but I assume it should be like any other case with any game. You can set the cursor to always be at window width/2 and window height/2. That will keep the mouse in the window. Then keep track of how much it moved before you set it back to that center position again. With that movement amount you can move the camera/move a custom 2d image. Im not sure if this is what your trying to achive but it sounds like it.

Share this post


Link to post
Share on other sites
No it's not bad practice at all. It's freaking annoying having the mouse cursor show up outside the window throwing your mouse control off in the game.

If you want to go to another window, just ALT-TAB. Or remember you're playing a game and everything else can wait. :-)

I know you can do this manually, I just wondered if XNA had a mode that would do it for you as it does a lot of other cool things for you. But yes Wolfdog, this is the effect I am looking at.

Every FPS I have played in windowed mode did what I talk about. I just now ran quake 2 in windowed mode and yep, no mouse cursor. In a FPS, having the mouse cursor show up outside the window causing the mouse control to go away in the game would be a bad thing. Actually, I've played many other games in a window that wasn't a FPS that took complete control over the mouse, now that I think about it.

When my game is running in a window, I want the game to own the mouse and if I need to switch to another window, ALT-TAB is just fine.

There's nothing at all wrong with this. Games have been doing this for a long time now, not all but a lot.

Share this post


Link to post
Share on other sites
Quote:
Original post by SirKnight
No it's not bad practice at all. It's freaking annoying having the mouse cursor show up outside the window throwing your mouse control off in the game.

If you want to go to another window, just ALT-TAB. Or remember you're playing a game and everything else can wait. :-)

I know you can do this manually, I just wondered if XNA had a mode that would do it for you as it does a lot of other cool things for you. But yes Wolfdog, this is the effect I am looking at.

Every FPS I have played in windowed mode did what I talk about. I just now ran quake 2 in windowed mode and yep, no mouse cursor. In a FPS, having the mouse cursor show up outside the window causing the mouse control to go away in the game would be a bad thing. Actually, I've played many other games in a window that wasn't a FPS that took complete control over the mouse, now that I think about it.

When my game is running in a window, I want the game to own the mouse and if I need to switch to another window, ALT-TAB is just fine.

There's nothing at all wrong with this. Games have been doing this for a long time now, not all but a lot.


Or you can just play the games full-screen. [wink] If I'm playing a game I'm not going to switch to another window so why play in a window?

Share this post


Link to post
Share on other sites
If I remember correctly, when in windowed mode, Quake 2 didn't allow the cursor to leave the confines of the window and naturally hid the cursor. Then if you brought up the console the cursor became visable and you could move it outside of the window.

I agree though that if your game is going to be in windowed mode natively, then hiding the cursor on users is a bad plan. If you are making it full-screen natively then the way I descibed (which I think is how Quake 2 did it) seems like a good way to go.

With regards to the original question of "how". The XNA beta's mouse support is pretty poor at best, so you will have to resort to WinForm methods to do what you are after.

Regards,
ViLiO

Share this post


Link to post
Share on other sites
Quote:
Original post by k00k
Simple fix guys .. the Microsoft.Xna.Framework.Game class has a property called .. IsMouseVisible so set it to true or false which ever you like and your done.


He is asking how to hide it outside the window in windowed mode.

Share this post


Link to post
Share on other sites

This topic is 3776 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