简体   繁体   English

C ++检查光标位置

[英]c++ check cursor position

im trying to see if the cursor is inside my game not on the menue or the border inside the game. 我试图查看光标是否在我的游戏内,而不是在菜单或游戏内的边框上。 i don't konw what function should i use? 我不知道我应该使用什么功能? i thought of using GetcursorPos() but is there better function? 我想到使用GetcursorPos(),但是有更好的功能吗?

GetCursorPos() returns the mouse position. GetCursorPos()返回鼠标位置。 ScreenToClient() is usually next. ScreenToClient()通常是下一个。 That works for polling the mouse. 这适用于轮询鼠标。

A more typical approach in a game loop is calling PeekMessage() inside the loop so you can see the WM_MOUSEMOVE message. 游戏循环中更典型的方法是在循环内部调用PeekMessage(),以便您可以看到WM_MOUSEMOVE消息。 More efficient because you don't burn any time worrying about the mouse when the user isn't moving it. 效率更高,因为当用户不移动鼠标时,您无需担心任何时间,就不用担心。 Or using some class library to implement the game, mouse handling is always part of it. 或使用某些类库来实现游戏,鼠标处理始终是其中的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM