游戏开发论坛

 找回密码
 立即注册
搜索
查看: 3374|回复: 6

怎么捕获鼠标消息并处理

[复制链接]

56

主题

758

帖子

768

积分

高级会员

Rank: 4

积分
768
发表于 2007-8-1 11:47:00 | 显示全部楼层 |阅读模式
众所周知,游戏循环控制游戏的命脉,可是如果想让游戏捕获鼠标消息后再由循环处理该怎么做呢?我是新手勤大家指教,谢谢!

1万

主题

1万

帖子

2万

积分

管理员

中级会员

Rank: 9Rank: 9Rank: 9

积分
20737
发表于 2007-8-1 13:27:00 | 显示全部楼层

Re:怎么捕获鼠标消息并处理

游?蛑芯褪窃O立一????B,一旦?入?????B就?始等待操作?入直至?入信息?取返回。

56

主题

758

帖子

768

积分

高级会员

Rank: 4

积分
768
 楼主| 发表于 2007-8-1 14:20:00 | 显示全部楼层

Re:怎么捕获鼠标消息并处理

该如何实现?

5

主题

755

帖子

757

积分

高级会员

Rank: 4

积分
757
发表于 2007-8-4 11:57:00 | 显示全部楼层

Re:怎么捕获鼠标消息并处理

在你画所有东西之前先得到更新一次所有的输入等等,不就可以了,在 render 函数前面加个 GetInputInfo类似

4

主题

13

帖子

27

积分

注册会员

Rank: 2

积分
27
发表于 2007-11-21 15:53:00 | 显示全部楼层

Re:怎么捕获鼠标消息并处理

游戏中有一个消息循环,当得到鼠标按下或者移动的消息时候会判断程序是否对这个消息做出相应,如果是则执行相应代码,如果不是则继续循环。(其它的消息包括键盘按下消息等等都是这个原理)

0

主题

769

帖子

1052

积分

金牌会员

Rank: 6Rank: 6

积分
1052
发表于 2007-11-23 00:25:00 | 显示全部楼层

Re:怎么捕获鼠标消息并处理

自己去翻DX SDK的说明文档看看
DirectInput那段写得很清楚的

18

主题

82

帖子

86

积分

注册会员

Rank: 2

积分
86
发表于 2007-11-25 18:41:00 | 显示全部楼层

Re:怎么捕获鼠标消息并处理

不知道是不是这个函数:
CWnd::GetCapture  
static CWnd* PASCAL GetCapture( );

Return Value

Identifies the window that has the mouse capture. It is NULL if no window has the mouse capture.

The return value may be temporary and should not be stored for later use.

Remarks

Retrieves the window that has the mouse capture. Only one window has the mouse capture at any given time. A window receives the mouse capture when the SetCapture member function is called. This window receives mouse input whether or not the cursor is within its borders.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-24 08:35

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表