[英]How do you handle a mouse cursor in the FPS game?
I'm making an FPS game.我正在制作一个FPS游戏。 In the FPS game, the mouse cursor is in the middle of the screen.在 FPS 游戏中,鼠标光标位于屏幕中间。 So I put the mouse cursor in the center with the next code.所以我把鼠标光标放在中心,下一个代码。 But how can I solve this problem when the camera stutters very much every time I move the mouse?但是当我每次移动鼠标时相机都非常卡顿时,我该如何解决这个问题呢?
SetCursorPos(CRenderMgr::GetInst()->GetResolution().fWidth / 2, CRenderMgr::GetInst()->GetResolution().fHeight / 2);
What you are doing is referred to as 'relative mode' mouse movement.您正在做的事情被称为“相对模式”鼠标移动。
For classic Win32, this is typically done using "raw input".对于经典 Win32,这通常使用“原始输入”来完成。 See this article<\/a> .见这篇文章<\/a>。
If you want "raw input" to also to work in a Remote Desktop, see this code<\/a> .如果您希望“原始输入”也可以在远程桌面中工作,请参阅此代码<\/a>。 In Remote Desktop, you don't get
MOUSE_MOVE_RELATIVE<\/code> data, and in normal desktop scenarios you never get
MOUSE_MOVE_ABSOLUTE<\/code> data.
在远程桌面中,您不会获得
MOUSE_MOVE_RELATIVE<\/code>数据,而在普通桌面场景中,您永远不会获得
MOUSE_MOVE_ABSOLUTE<\/code>数据。
<\/blockquote>
For UWP, this is implemented as mentioned in
this article<\/a> .对于 UWP,这是按照本文<\/a>所述实现的。
You can see the
Mouse<\/code> class in the
DirectX Tool Kit<\/a> .
您可以在DirectX Tool Kit<\/a>中看到
Mouse<\/code>类。
<\/blockquote>"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.