设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: jiahui5592986
打印 上一主题 下一主题

[已经解决] 关于禁止键盘按键的问题

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1556
在线时间
626 小时
注册时间
2010-8-5
帖子
451
11
 楼主| 发表于 2012-7-24 09:44:04 | 只看该作者
zxcgood2009 发表于 2012-7-23 21:20
我说你有必要没。
开始游戏后F1,把x换成别的键,不就得了。
或者把,按下x键后,播放短暂的空白音乐,不做 ...

那Ctrl呢?游戏发布的时候呢.这个方法¥@#¥#


‘‘──jiahui5592986于2012-7-24 09:45补充以下内容:

有效.........
’’
回复 支持 反对

使用道具 举报

Lv3.寻梦者

双子人

梦石
0
星屑
3190
在线时间
3618 小时
注册时间
2009-4-4
帖子
4154

开拓者

12
发表于 2012-7-24 12:29:06 | 只看该作者
可以将你的全键盘脚本换一下。
判断方法(以A键为例):Input.press?(65)
冻结方法(以B键为例):Input.disable(66)
取消冻结方法(以C键为例):Input.able(67)
对应按键的列表:
LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  LETTERS['Y'] = 89; LETTERS['Z'] = 90
  NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
   NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]


下面是脚本(直接插入)
  1. #===============================================================================
  2. #
  3. # OriginalWij and Yanfly Collaboration - Keyboard Input
  4. # Last Date Updated: 2010.06.12
  5. # Level: Normal
  6. #
  7. # This is a utility script that provides the functionality to return inputs
  8. # from the keyboard as well as free up more keys to be used in the Input module.
  9. # This script will also replace Scene_Name and allow for direct keyboard input
  10. # to type in an actor's name as well as fix the maximum characters shown from
  11. # the default base script.
  12. #
  13. #===============================================================================
  14. # Updates
  15. # -----------------------------------------------------------------------------
  16. # o 2010.06.12 - Started and Finished Script.
  17. #===============================================================================
  18. # Instructions
  19. # -----------------------------------------------------------------------------
  20. # To install this script, open up your script editor and copy/paste this script
  21. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  22. #
  23. # For users:
  24. #   The Name Input event has been now replaced. It not longer takes you to the
  25. #   name entry scene, but instead, allows the player to enter in the name of
  26. #   the desired actor right in the current screen itself without needing to
  27. #   change the scene altogether.
  28. #
  29. # For scripters:
  30. #   For those curious as to how to retrieve certain letters while coding their
  31. #   Input commands, use the following as reference
  32. #   
  33. #   LETTERS['A'] through LETTERS['Z']
  34. #     This returns true if the respective letter from A through Z is pressed.
  35. #   
  36. #   NUMBERS[0] through NUMBERS[9]
  37. #     This returns true if the respective number on the top row of the keyboard
  38. #     is pressed. This does not include the numberpad.
  39. #   
  40. #   NUMPAD[0] through NUMPAD[9]
  41. #     This returns true if the respective number in the number pad is pressed.
  42. #     This does not include the numbers found at the top row of the keyboard.
  43. #   
  44. #   Symbol Keys
  45. #     
  46. #     USCORE  - This returns true if the - key is pressed.
  47. #     EQUALS  - This returns true if the = key is pressed.
  48. #     SCOLON  - This returns true if the ; key is pressed.
  49. #     QUOTE   - This returns true if the ' key is pressed.
  50. #     COMMA   - This returns true if the , key is pressed.
  51. #     PERIOD  - This returns true if the . key is pressed.
  52. #     SLASH   - This returns true if the / key is pressed.
  53. #     BSLASH  - This returns true if the \ key is pressed.
  54. #     LBRACE  - This returns true if the [ key is pressed.
  55. #     RBRACE  - This returns true if the ] key is pressed.
  56. #     TILDE   - This returns true if the ~ key is pressed.
  57. #   
  58. #   Command Keys
  59. #     
  60. #     BACK    - This returns true if the backspace key is pressed.
  61. #     ENTER   - This returns true if the enter/return key is pressed.
  62. #     SPACE   - This returns true if the space bar is pressed.
  63. #     ESC     - This returns true if the escape key is pressed.
  64. #   
  65. #   Module Methods
  66. #     
  67. #     Input.typing?
  68. #       To check if typing is occurring. Returns true or false.
  69. #     
  70. #     Input.key_type
  71. #       Returns whatever key is being used to type as a string.
  72. #   
  73. #   Example:
  74. #   
  75. #     if Input.typing?
  76. #       string = Input.key_type
  77. #     end
  78. #
  79. #===============================================================================

  80. $imported = {} if $imported == nil
  81. $imported["KeyboardInput"] = true

  82. #===============================================================================
  83. # Editting anything past this point may potentially result in causing computer
  84. # damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
  85. # Therefore, edit at your own risk.
  86. #===============================================================================

  87. #===============================================================================
  88. # Input
  89. #===============================================================================

  90. class << Input  
  91.   #--------------------------------------------------------------------------
  92.   # Aliases (Mods - Linked to Module) - Created by OriginalWij
  93.   #--------------------------------------------------------------------------
  94.   alias ow_dt_i_press press? unless $@
  95.   alias ow_dt_i_trigger trigger? unless $@
  96.   alias ow_dt_i_repeat repeat? unless $@
  97.   alias ow_dt_i_update update unless $@
  98. end

  99. module Input
  100.   #--------------------------------------------------------------------------
  101.   # constants - Created by OriginalWij and Yanfly
  102.   #--------------------------------------------------------------------------
  103.   LETTERS = {}        
  104.   LETTERS['A'] = 65; LETTERS['B'] = 66; LETTERS['C'] = 67; LETTERS['D'] = 68
  105.   LETTERS['E'] = 69; LETTERS['F'] = 70; LETTERS['G'] = 71; LETTERS['H'] = 72
  106.   LETTERS['I'] = 73; LETTERS['J'] = 74; LETTERS['K'] = 75; LETTERS['L'] = 76
  107.   LETTERS['M'] = 77; LETTERS['N'] = 78; LETTERS['O'] = 79; LETTERS['P'] = 80
  108.   LETTERS['Q'] = 81; LETTERS['R'] = 82; LETTERS['S'] = 83; LETTERS['T'] = 84
  109.   LETTERS['U'] = 85; LETTERS['V'] = 86; LETTERS['W'] = 87; LETTERS['X'] = 88
  110.   LETTERS['Y'] = 89; LETTERS['Z'] = 90
  111.   NUMBERS = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  112.   NUMPAD = [96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  113.   BACK   = 138; ENTER  = 143; SPACE  = 32;  SCOLON = 186; ESC    = 157
  114.   QUOTE  = 222; EQUALS = 187; COMMA  = 188; USCORE = 189; PERIOD = 190
  115.   SLASH  = 191; LBRACE = 219; RBRACE = 221; BSLASH = 220; TILDE  = 192
  116.   F10    = 121; F11    = 122; CAPS   = 20;  NMUL   = 106; NPLUS  = 107
  117.   NSEP   = 108; NMINUS = 109; NDECI  = 110; NDIV   = 111; Extras =
  118.   [USCORE, EQUALS, LBRACE, RBRACE, BSLASH, SCOLON, QUOTE, COMMA, PERIOD, SLASH,
  119.    NMUL, NPLUS, NSEP, NMINUS, NDECI, NDIV]

  120.   #——————————————————————————————
  121.   # 冻结
  122.   #————————————————————————————
  123.   def able(key)
  124.     @disable = [] if @disable == nil
  125.     @disable.delete(key)
  126.   end
  127.   def disable(key)
  128.     @disable = [] if @disable == nil
  129.     @disable.push(key)
  130.   end
  131.   #--------------------------------------------------------------------------
  132.   # initial module settings - Created by OriginalWij and Yanfly
  133.   #--------------------------------------------------------------------------
  134.   GetKeyState = Win32API.new("user32", "GetAsyncKeyState", "i", "i")
  135.   GetCapState = Win32API.new("user32", "GetKeyState", "i", "i")
  136.   KeyRepeatCounter = {}
  137.   module_function
  138.   #--------------------------------------------------------------------------
  139.   # alias method: update - Created by OriginalWij
  140.   #--------------------------------------------------------------------------
  141.   def update
  142.     ow_dt_i_update
  143.     for key in KeyRepeatCounter.keys
  144.       next if @disable.include?(key)
  145.       if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  146.         KeyRepeatCounter[key] += 1
  147.       else
  148.         KeyRepeatCounter.delete(key)
  149.       end
  150.     end
  151.   end
  152.   
  153.   #--------------------------------------------------------------------------
  154.   # alias method: press? - Created by OriginalWij
  155.   #--------------------------------------------------------------------------
  156.   def press?(key)
  157.     return if @disable.include?(key)
  158.     return ow_dt_i_press(key) if key < 30
  159.     adjusted_key = adjust_key(key)
  160.     return true unless KeyRepeatCounter[adjusted_key].nil?
  161.     return key_pressed?(adjusted_key)
  162.   end
  163.   
  164.   #--------------------------------------------------------------------------
  165.   # alias method: trigger? - Created by OriginalWij
  166.   #--------------------------------------------------------------------------
  167.   def trigger?(key)
  168.     return if @disable.include?(key)
  169.     return ow_dt_i_trigger(key) if key < 30
  170.     adjusted_key = adjust_key(key)
  171.     count = KeyRepeatCounter[adjusted_key]
  172.     return ((count == 0) or (count.nil? ? key_pressed?(adjusted_key) : false))
  173.   end
  174.   
  175.   #--------------------------------------------------------------------------
  176.   # alias method: repeat? - Created by OriginalWij
  177.   #--------------------------------------------------------------------------
  178.   def repeat?(key)
  179.     return if @disable.include?(key)
  180.     return ow_dt_i_repeat(key) if key < 30
  181.     adjusted_key = adjust_key(key)
  182.     count = KeyRepeatCounter[adjusted_key]
  183.     return true if count == 0
  184.     if count.nil?
  185.       return key_pressed?(adjusted_key)
  186.     else
  187.       return (count >= 23 and (count - 23) % 6 == 0)
  188.     end
  189.   end
  190.   
  191.   #--------------------------------------------------------------------------
  192.   # new method: adjust_key - Created by OriginalWij
  193.   #--------------------------------------------------------------------------
  194.   def adjust_key(key)
  195.     return if @disable.include?(key)
  196.     key -= 130 if key.between?(130, 158)
  197.     return key
  198.   end
  199.   
  200.   #--------------------------------------------------------------------------
  201.   # new method: key_pressed? - Created by OriginalWij
  202.   #--------------------------------------------------------------------------
  203.   def key_pressed?(key)
  204.     return if @disable.include?(key)
  205.     if (GetKeyState.call(key).abs & 0x8000 == 0x8000)
  206.       KeyRepeatCounter[key] = 0
  207.       return true
  208.     end
  209.     return false
  210.   end
  211.   
  212.   #--------------------------------------------------------------------------
  213.   # new method: typing? - Created by Yanfly
  214.   #--------------------------------------------------------------------------
  215.   def typing?
  216.     return true if repeat?(SPACE)
  217.     for i in 'A'..'Z'
  218.       return true if repeat?(LETTERS[i])
  219.     end
  220.     for i in 0...NUMBERS.size
  221.       return true if repeat?(NUMBERS[i])
  222.       return true if repeat?(NUMPAD[i])
  223.     end
  224.     for key in Extras
  225.       return true if repeat?(key)
  226.     end
  227.     return false
  228.   end
  229.   
  230.   #--------------------------------------------------------------------------
  231.   # new method: key_type - Created by Yanfly
  232.   #--------------------------------------------------------------------------
  233.   def key_type
  234.     return " " if repeat?(SPACE)
  235.     for i in 'A'..'Z'
  236.       next unless repeat?(LETTERS[i])
  237.       return upcase? ? i.upcase : i.downcase
  238.     end
  239.     for i in 0...NUMBERS.size
  240.       return i.to_s if repeat?(NUMPAD[i])
  241.       if !press?(SHIFT)
  242.         return i.to_s if repeat?(NUMBERS[i])
  243.       elsif repeat?(NUMBERS[i])
  244.         case i
  245.         when 1; return "!"
  246.         when 2; return "@"
  247.         when 3; return "#"
  248.         when 4; return "$"
  249.         when 5; return "%"
  250.         when 6; return "^"
  251.         when 7; return "&"
  252.         when 8; return "*"
  253.         when 9; return "("
  254.         when 0; return ")"
  255.         end
  256.       end
  257.     end
  258.     for key in Extras
  259.       next unless repeat?(key)
  260.       case key
  261.       when USCORE; return press?(SHIFT) ? "_" : "-"
  262.       when EQUALS; return press?(SHIFT) ? "+" : "="
  263.       when LBRACE; return press?(SHIFT) ? "{" : "["
  264.       when RBRACE; return press?(SHIFT) ? "}" : "]"
  265.       when BSLASH; return press?(SHIFT) ? "|" : "\\"
  266.       when SCOLON; return press?(SHIFT) ? ":" : ";"
  267.       when QUOTE;  return press?(SHIFT) ? '"' : "'"
  268.       when COMMA;  return press?(SHIFT) ? "<" : ","
  269.       when PERIOD; return press?(SHIFT) ? ">" : "."
  270.       when SLASH;  return press?(SHIFT) ? "?" : "/"
  271.       when NMUL;   return "*"
  272.       when NPLUS;  return "+"
  273.       when NSEP;   return ","
  274.       when NMINUS; return "-"
  275.       when NDECI;  return "."
  276.       when NDIV;   return "/"
  277.       end
  278.     end
  279.     return ""
  280.   end
  281.   
  282.   #--------------------------------------------------------------------------
  283.   # new method: upcase? - Created by Yanfly
  284.   #--------------------------------------------------------------------------
  285.   def upcase?
  286.     return !press?(SHIFT) if GetCapState.call(CAPS) == 1
  287.     return true if press?(SHIFT)
  288.     return false
  289.   end
  290.   
  291. end # Input
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
79
在线时间
193 小时
注册时间
2011-6-29
帖子
34
13
发表于 2012-7-24 18:25:50 | 只看该作者
jiahui5592986 发表于 2012-7-23 17:06
貌似不可以哦

不会吧,屏蔽按键可以使用。只不过效果不太稳定,好像只有在特定的情况下发挥作用。
比如说主角死亡时执行屏蔽按键就起作用了,你可以试一试。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-30 01:40

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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