[.net] XNA mouse cursor
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
Not using XNA. You'd have to call the Win API. Why would you want to do this anyway? Kind of defeats the purpose of running in a window.
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?
Try creating a new Windows Game project and run it straight away.
Does it hide the mouse cursor?
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.
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.
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.
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.
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.
So anyway, since XNA wont do this for me I'll have to continue doing this myself like I always have done.
Case closed. :-) Thanks anyway.
Case closed. :-) Thanks anyway.
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?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement