游戏开发论坛

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

请教一个按键的问题

[复制链接]

19

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2005-3-27 13:31:00 | 显示全部楼层 |阅读模式
如何判断多次按键呢?比如说VK_UP,这样只能判断一次如何判断两次呢?
比如说按下VK_UP一次执行一些命令,再按一下VK_UP执行另一些命令,应该怎么做呢?

96

主题

529

帖子

539

积分

高级会员

Rank: 4

积分
539
发表于 2005-3-27 13:37:00 | 显示全部楼层

Re:请教一个按键的问题

用timeGettime函数,获得两次按键的时间间隔,如果时间间隔一定短,则算为双按键.

19

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2005-3-27 13:56:00 | 显示全部楼层

Re:请教一个按键的问题

我做了一个阴影随光线同时渐变的房间,屋里有个灯,我想按一下灯亮再按一下不亮.请问有特定的方法吗?比如VK_UP==1之类的?

19

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2005-3-27 13:58:00 | 显示全部楼层

Re:请教一个按键的问题

但是格式我不会写啊:..(
怎么用timeGetTime呢

96

主题

529

帖子

539

积分

高级会员

Rank: 4

积分
539
发表于 2005-3-27 14:04:00 | 显示全部楼层

Re:请教一个按键的问题

摘自MSDN

timeGetTime
The timeGetTime function retrieves the system time, in milliseconds. The system time is the time elapsed since Windows was started.

DWORD timeGetTime(VOID);
Parameters
This function does not take parameters.

Return Values
Returns the system time, in milliseconds.

Remarks
The only difference between this function and the timeGetSystemTime function is that timeGetSystemTime uses the MMTIME structure to return the system time. The timeGetTime function has less overhead than timeGetSystemTime.

Note that the value returned by the timeGetTime function is a DWORD value. The return value wraps around to 0 every 2^32 milliseconds, which is about 49.71 days.This can cause problems in code that directly uses the timeGetTime return value in computations, particularly where the value is used to control code execution. You should always use the difference between two timeGetTime return values in computations.

Windows NT: The default precision of the timeGetTime function can be five milliseconds or more, depending on the machine. You can use the timeBeginPeriod and timeEndPeriod functions to increase the precision of timeGetTime. If you do so, the minimum difference between successive values returned by timeGetTime can be as large as the minimum period value set using timeBeginPeriod and timeEndPeriod. Use the QueryPerformanceCounter and QueryPerformanceFrequency functions to measure short time intervals at a high resolution,

Windows 95: The default precision of the timeGetTime function is 1 millisecond. In other words, the timeGetTime function can return successive values that differ by just 1 millisecond. This is true no matter what calls have been made to the timeBeginPeriod and timeEndPeriod functions.

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mmsystem.h.
  Import Library: Use winmm.lib.

26

主题

324

帖子

325

积分

中级会员

Rank: 3Rank: 3

积分
325
QQ
发表于 2005-3-27 14:10:00 | 显示全部楼层

Re:请教一个按键的问题

设置一个标示灯亮的标志就可以了,如:bLightUp,然后判断该变量,若亮着就关掉,若关着就点亮。

19

主题

102

帖子

102

积分

注册会员

Rank: 2

积分
102
发表于 2005-3-27 14:13:00 | 显示全部楼层

Re:请教一个按键的问题

哇明白一些了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-12-25 01:00

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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