查看: 3169|回复: 13

[已经解决] 怎么改移动键

[复制链接]
梦石
0
星屑
1295
在线时间
368 小时
注册时间
2016-6-10
回帖
32
发表于 2016-10-7 13:41:02 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
怎么把↕↔改为WSAD,把确定键改为J,取消键改为K?听说游戏时按F1就可以改,怎么改啊?
梦石
0
星屑
1295
在线时间
368 小时
注册时间
2016-6-10
回帖
32
 楼主| 发表于 2016-10-8 17:41:06 | 显示全部楼层
有人来解答一下吗{:2_264:}
回复

使用道具 举报

梦石
1
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2016-10-8 19:47:42 | 显示全部楼层
只能通过全键盘脚本进行,RM自带的键位设置并不支持全键盘
回复

使用道具 举报

梦石
0
星屑
1295
在线时间
368 小时
注册时间
2016-6-10
回帖
32
 楼主| 发表于 2016-10-8 19:49:14 | 显示全部楼层
喵呜喵5 发表于 2016-10-8 19:47
只能通过全键盘脚本进行,RM自带的键位设置并不支持全键盘

能发一个范例吗{:2_249:}
回复

使用道具 举报

梦石
0
星屑
6891
在线时间
7027 小时
注册时间
2013-11-2
回帖
1263

开拓者剧作品鉴家

发表于 2016-10-17 09:40:37 | 显示全部楼层
本帖最后由 RaidenInfinity 于 2016-10-17 22:37 编辑

经改良过的全键盘脚本(我上个作品用的,正好可以帮忙)。
脚本上方是方向键,确认键,取消键的键位定义。
不过要注意的是,使用了此脚本后,F1设置对这些键位的改动无效。

  1. module Input
  2.        
  3.         #方向键
  4.   #下 - 下方向键(DOWN) 或 S
  5.         def self.down?(sym); Keys.send(sym,Keys::DOWN) || Keys.send(sym,Keys::S) end       
  6.         #左 - 左方向键(LEFT) 或 A
  7.   def self.left?(sym); Keys.send(sym,Keys::LEFT) || Keys.send(sym,Keys::A) end       
  8.         #右 - 右方向键(RIGHT) 或 D
  9.   def self.right?(sym); Keys.send(sym,Keys::RIGHT) || Keys.send(sym,Keys::D) end
  10.         #上 - 上方向键(UP) 或 W
  11.   def self.up?(sym); Keys.send(sym,Keys::UP) || Keys.send(sym,Keys::W) end
  12.        
  13.         #确认键 - Z 或 J
  14.         def self.c?(sym)
  15.                 Keys.send(sym,Keys::Z) || Keys.send(sym,Keys::J)
  16.         end
  17.        
  18.   #取消键 - X 或 K
  19.         def self.b?(sym)
  20.                 Keys.send(sym,Keys::X) || Keys.send(sym,Keys::K)
  21.    
  22.         end
  23.   
  24. end

  25. #以下为脚本核心,请勿随意修改
  26. #≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  27. # ** Glitchfinder's Key Input Module              [RPG Maker XP] [RPG Maker VX]
  28. #    Version 1.00
  29. #------------------------------------------------------------------------------
  30. #  This script helps scripters to use the full range of keys on any keyboard,
  31. #  without being limited by the default Input Module.
  32. #==============================================================================
  33. # * Version History
  34. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  35. #   Version 1.00 ------------------------------------------------- (2010-03-18)
  36. #     - Initial version
  37. #     - Author: Glitchfinder
  38. #==============================================================================
  39. # * Instructions
  40. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  41. #  Place this script above Main, and below the default scripts. (I realize this
  42. #  is obvious to most, but some people don't get it.)
  43. #
  44. #  This module is automatically updated by the default Input module, which
  45. #  means that the only time you need to call the update method is in a scene
  46. #  that does not update the default Input module.
  47. #
  48. #  This module does not break the functionality of the default Input module.
  49. #
  50. #  If you wish to read keys from a gamepad, you must still use the default
  51. #  input module to do so.
  52. #
  53. #  To use this module, simply use one of the four methods (press?(key),
  54. #  trigger?(key), repeat?(key), or release?(key)), where key is the index of
  55. #  the key you want to check. Key may also be used as Keys::KEYNAME. For a list
  56. #  of acceptable key names, look below the header.
  57. #==============================================================================
  58. # * Method List
  59. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  60. #  Keys.update
  61. #    Updates keyboard input. Calls to this method are not necessary unless the
  62. #    default Input module is not being updated.
  63. #
  64. #  Keys.press?(key)
  65. #    Determines whether the button determined by key is currently being
  66. #    pressed. If the button is being pressed, returns true. If not, returns
  67. #    false.
  68. #
  69. #  Keys.trigger?(key)
  70. #    Determines whether the button determined by key is being pressed again.
  71. #    "Pressed again" is seen as time having passed between the button being not
  72. #    pressed and being pressed. If the button is being pressed, returns true.
  73. #    If not, returns false.
  74. #
  75. #  Keys.repeat?(key)
  76. #    Determines whether the button determined by key is being pressed again.
  77. #    Unlike trigger?(), this takes into account the repeat input of a button
  78. #    being held down continuously. If the button is being pressed, returns
  79. #    true. If not, returns false.
  80. #
  81. #  Keys.release?(key)
  82. #    Determines whether the button determined by key has just been released. If
  83. #    the button has been released, returns true. If not, returns false.
  84. #==============================================================================
  85. # *Glitchfinder's Advice
  86. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  87. #  This script is meant for people with a medium or advanced level of scripting
  88. #  knowledge and ability, or for those using scripts that require this module.
  89. #==============================================================================
  90. # * Contact
  91. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  92. #  Glitchfinder, the author of this script, may be contacted through his
  93. #  website, found at [url]http://www.glitchkey.com[/url]
  94. #
  95. #  You may also find Glitchfinder at [url]http://www.hbgames.org[/url]
  96. #==============================================================================
  97. # * Usage
  98. #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  99. #  This script may be used with the following terms and conditions:
  100. #
  101. #    1. This script is free to use in any noncommercial project. If you wish to
  102. #       use this script in a commercial (paid) project, please contact
  103. #       Glitchfinder at his website.
  104. #    2. This script may only be hosted at the following domains:
  105. #         [url]http://www.glitchkey.com[/url]
  106. #         [url]http://www.hbgames.org[/url]
  107. #    3. If you wish to host this script elsewhere, please contact Glitchfinder.
  108. #    4. If you wish to translate this script, please contact Glitchfinder. He
  109. #       will need the web address that you plan to host the script at, as well
  110. #       as the language this script is being translated to.
  111. #    5. This header must remain intact at all times.
  112. #    6. Glitchfinder remains the sole owner of this code. He may modify or
  113. #       revoke this license at any time, for any reason.
  114. #    7. Any code derived from code within this script is owned by Glitchfinder,
  115. #       and you must have his permission to publish, host, or distribute his
  116. #       code.
  117. #    8. This license applies to all code derived from the code within this
  118. #       script.
  119. #    9. If you use this script within your project, you must include visible
  120. #       credit to Glitchfinder, within reason.
  121. #≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

  122. #==============================================================================
  123. # ** Keys
  124. #------------------------------------------------------------------------------
  125. #  This module performs key input processing
  126. #==============================================================================

  127. module Keys
  128.         #--------------------------------------------------------------------------
  129.         # * Miscellaneous Keys
  130.         #--------------------------------------------------------------------------
  131.         CANCEL              = 0x03 # Control-Break Processing
  132.         BACKSPACE           = 0x08 # Backspace Key
  133.         TAB                 = 0x09 # Tab Key
  134.         CLEAR               = 0x0C # Clear Key
  135.         RETURN              = 0x0D # Enter Key
  136.         SHIFT               = 0x10 # Shift Key
  137.         CONTROL             = 0x11 # Ctrl Key
  138.         MENU                = 0x12 # Alt Key
  139.         PAUSE               = 0x13 # Pause Key
  140.         ESCAPE              = 0x1B # Esc Key
  141.         CONVERT             = 0x1C # IME Convert Key
  142.         NONCONVERT          = 0x1D # IME Nonconvert Key
  143.         ACCEPT              = 0x1E # IME Accept Key
  144.         SPACE               = 0x20 # Space Bar Key (Space, usually blank)
  145.         PRIOR               = 0x21 # Page Up Key
  146.         NEXT                = 0x22 # Page Down Key
  147.         ENDS                = 0x23 # End Key
  148.         HOME                = 0x24 # Home Key
  149.         LEFT                = 0x25 # Left Arrow Key
  150.         UP                  = 0x26 # Up Arrow Key
  151.         RIGHT               = 0x27 # Right Arrow Key
  152.         DOWN                = 0x28 # Down Arrow Key
  153.         SELECT              = 0x29 # Select Key
  154.         PRINT               = 0x2A # Print Key
  155.         EXECUTE             = 0x2B # Execute Key
  156.         SNAPSHOT            = 0x2C # Print Screen Key
  157.         DELETE              = 0x2E # Delete Key
  158.         HELP                = 0x2F # Help Key
  159.         LSHIFT              = 0xA0 # Left Shift Key
  160.         RSHIFT              = 0xA1 # Right Shift Key
  161.         LCONTROL            = 0xA2 # Left Control Key (Ctrl)
  162.         RCONTROL            = 0xA3 # Right Control Key (Ctrl)
  163.         LMENU               = 0xA4 # Left Menu Key (Alt)
  164.         RMENU               = 0xA5 # Right Menu Key (Alt)
  165.         PACKET              = 0xE7 # Used to Pass Unicode Characters as Keystrokes
  166.         #--------------------------------------------------------------------------
  167.         # * Number Keys
  168.         #--------------------------------------------------------------------------
  169.         N0                  = 0x30 # 0 Key
  170.         N1                  = 0x31 # 1 Key
  171.         N2                  = 0x32 # 2 Key
  172.         N3                  = 0x33 # 3 Key
  173.         N4                  = 0x34 # 4 Key
  174.         N5                  = 0x35 # 5 Key
  175.         N6                  = 0x36 # 6 Key
  176.         N7                  = 0x37 # 7 Key
  177.         N8                  = 0x38 # 8 Key
  178.         N9                  = 0x39 # 9 Key
  179.         #--------------------------------------------------------------------------
  180.         # * Letter Keys
  181.         #--------------------------------------------------------------------------
  182.         A                   = 0x41 # A Key
  183.         B                   = 0x42 # B Key
  184.         C                   = 0x43 # C Key
  185.         D                   = 0x44 # D Key
  186.         E                   = 0x45 # E Key
  187.         F                   = 0x46 # F Key
  188.         G                   = 0x47 # G Key
  189.         H                   = 0x48 # H Key
  190.         I                   = 0x49 # I Key
  191.         J                   = 0x4A # J Key
  192.         K                   = 0x4B # K Key
  193.         L                   = 0x4C # L Key
  194.         M                   = 0x4D # M Key
  195.         N                   = 0x4E # N Key
  196.         O                   = 0x4F # O Key
  197.         P                   = 0x50 # P Key
  198.         Q                   = 0x51 # Q Key
  199.         R                   = 0x52 # R Key
  200.         S                   = 0x53 # S Key
  201.         T                   = 0x54 # T Key
  202.         U                   = 0x55 # U Key
  203.         V                   = 0x56 # V Key
  204.         W                   = 0x57 # W Key
  205.         X                   = 0x58 # X Key
  206.         Y                   = 0x59 # Y Key
  207.         Z                   = 0x5A # Z Key
  208.         #--------------------------------------------------------------------------
  209.         # * Windows Keys
  210.         #--------------------------------------------------------------------------
  211.         LWIN                = 0x5B # Left Windows Key (Natural keyboard)
  212.         RWIN                = 0x5C # Right Windows Key (Natural Keyboard)
  213.         APPS                = 0x5D # Applications Key (Natural keyboard)
  214.         SLEEP               = 0x5F # Computer Sleep Key
  215.         BROWSER_BACK        = 0xA6 # Browser Back Key
  216.         BROWSER_FORWARD     = 0xA7 # Browser Forward Key
  217.         BROWSER_REFRESH     = 0xA8 # Browser Refresh Key
  218.         BROWSER_STOP        = 0xA9 # Browser Stop Key
  219.         BROWSER_SEARCH      = 0xAA # Browser Search Key
  220.         BROWSER_FAVORITES   = 0xAB # Browser Favorites Key
  221.         BROWSER_HOME        = 0xAC # Browser Start and Home Key
  222.         VOLUME_MUTE         = 0xAD # Volume Mute Key
  223.         VOLUME_DOWN         = 0xAE # Volume Down Key
  224.         VOLUME_UP           = 0xAF # Volume Up Key
  225.         MEDIA_NEXT_TRACK    = 0xB0 # Next Track Key
  226.         MEDIA_PREV_TRACK    = 0xB1 # Previous Track Key
  227.         MEDIA_STOP          = 0xB2 # Stop Media Key
  228.         MEDIA_PLAY_PAUSE    = 0xB3 # Play/Pause Media Key
  229.         LAUNCH_MAIL         = 0xB4 # Start Mail Key
  230.         LAUNCH_MEDIA_SELECT = 0xB5 # Select Media Key
  231.         LAUNCH_APP1         = 0xB6 # Start Application 1 Key
  232.         LAUNCH_APP2         = 0xB7 # Start Application 2 Key
  233.         PROCESSKEY          = 0xE5 # IME Process Key
  234.         ATTN                = 0xF6 # Attn Key
  235.         CRSEL               = 0xF7 # CrSel Key
  236.         EXSEL               = 0xF8 # ExSel Key
  237.         EREOF               = 0xF9 # Erase EOF Key
  238.         PLAY                = 0xFA # Play Key
  239.         ZOOM                = 0xFB # Zoom Key
  240.         PA1                 = 0xFD # PA1 Key
  241.         #--------------------------------------------------------------------------
  242.         # * Number Pad Keys
  243.         #--------------------------------------------------------------------------
  244.         NUMPAD0             = 0x60 # Numeric Keypad 0 Key
  245.         NUMPAD1             = 0x61 # Numeric Keypad 1 Key
  246.         NUMPAD2             = 0x62 # Numeric Keypad 2 Key
  247.         NUMPAD3             = 0x63 # Numeric Keypad 3 Key
  248.         NUMPAD4             = 0x64 # Numeric Keypad 4 Key
  249.         NUMPAD5             = 0x65 # Numeric Keypad 5 Key
  250.         NUMPAD6             = 0x66 # Numeric Keypad 6 Key
  251.         NUMPAD7             = 0x67 # Numeric Keypad 7 Key
  252.         NUMPAD8             = 0x68 # Numeric Keypad 8 Key
  253.         NUMPAD9             = 0x69 # Numeric Keypad 9 Key
  254.         MULTIPLY            = 0x6A # Multiply Key (*)
  255.         ADD                 = 0x6B # Add Key (+)
  256.         SEPARATOR           = 0x6C # Separator Key
  257.         SUBTRACT            = 0x6D # Subtract Key (-)
  258.         DECIMAL             = 0x6E # Decimal Key (.)
  259.         DIVIDE              = 0x6F # Divide Key (/)
  260.         #--------------------------------------------------------------------------
  261.         # * Function Keys
  262.         #--------------------------------------------------------------------------
  263.         F1                  = 0x70 # F1 Key
  264.         F2                  = 0x71 # F2 Key
  265.         F3                  = 0x72 # F3 Key
  266.         F4                  = 0x73 # F4 Key
  267.         F5                  = 0x74 # F5 Key
  268.         F6                  = 0x75 # F6 Key
  269.         F7                  = 0x76 # F7 Key
  270.         F8                  = 0x77 # F8 Key
  271.         F9                  = 0x78 # F9 Key
  272.         F10                 = 0x79 # F10 Key
  273.         F11                 = 0x7A # F11 Key
  274.         F12                 = 0x7B # F12 Key
  275.         F13                 = 0x7C # F13 Key
  276.         F14                 = 0x7D # F14 Key
  277.         F15                 = 0x7E # F15 Key
  278.         F16                 = 0x7F # F16 Key
  279.         F17                 = 0x80 # F17 Key
  280.         F18                 = 0x81 # F18 Key
  281.         F19                 = 0x82 # F19 Key
  282.         F20                 = 0x83 # F20 Key
  283.         F21                 = 0x84 # F21 Key
  284.         F22                 = 0x85 # F22 Key
  285.         F23                 = 0x86 # F23 Key
  286.         F24                 = 0x87 # F24 Key
  287.         #--------------------------------------------------------------------------
  288.         # * Toggle Keys
  289.         #--------------------------------------------------------------------------
  290.         CAPITAL             = 0x14 # Caps Lock Key
  291.         KANA                = 0x15 # IME Kana Mode Key
  292.         HANGUL              = 0x15 # IME Hangul Mode Key
  293.         JUNJA               = 0x17 # IME Junja Mode Key
  294.         FINAL               = 0x18 # IME Final Mode Key
  295.         HANJA               = 0x19 # IME Hanja Mode Key
  296.         KANJI               = 0x19 # IME Kanji Mode Key
  297.         MODECHANGE          = 0x1F # IME Mode Change Request Key
  298.         INSERT              = 0x2D # Insert Key
  299.         NUMLOCK             = 0x90 # Num Lock Key
  300.         SCROLL              = 0x91 # Scroll Lock Key
  301.         #--------------------------------------------------------------------------
  302.         # * OEM Keys (Vary by keyboard)
  303.         #--------------------------------------------------------------------------
  304.         OEM_1               = 0xBA # Misc Characters (; : in USA 101/102 Keyboards)
  305.         OEM_PLUS            = 0xBB # + = Key
  306.         OEM_COMMA           = 0xBC # , < Key
  307.         OEM_MINUS           = 0xBD # - _ Key
  308.         OEM_PERIOD          = 0xBE # . > Key
  309.         OEM_2               = 0xBF # Misc Characters (/ ? in USA 101/102 Keyboards)
  310.         OEM_3               = 0xC0 # Misc Characters (` ~ in USA 101/102 Keyboards)
  311.         OEM_4               = 0xDB # Misc Characters ([ { in USA 101/102 Keyboards)
  312.         OEM_5               = 0xDC # Misc Characters (\ | in USA 101/102 Keyboards)
  313.         OEM_6               = 0xDD # Misc Characters (] } in USA 101/102 Keyboards)
  314.         OEM_7               = 0xDE # Misc Characters (' " in USA 101/102 Keyboards)
  315.         OEM_8               = 0xDF # Misc Characters (Varies by Keyboard)
  316.         OEM_9               = 0xE1 # OEM Specific
  317.         OEM_10              = 0x92 # OEM Specific
  318.         OEM_11              = 0x93 # OEM Specific
  319.         OEM_12              = 0x94 # OEM Specific
  320.         OEM_13              = 0x95 # OEM Specific
  321.         OEM_14              = 0x96 # OEM Specific
  322.         OEM_15              = 0xE3 # OEM Specific
  323.         OEM_16              = 0xE4 # OEM Specific
  324.         OEM_17              = 0xE6 # OEM Specific
  325.         OEM_18              = 0xE9 # OEM Specific
  326.         OEM_19              = 0xEA # OEM Specific
  327.         OEM_20              = 0xEB # OEM Specific
  328.         OEM_21              = 0xEC # OEM Specific
  329.         OEM_22              = 0xED # OEM Specific
  330.         OEM_23              = 0xEE # OEM Specific
  331.         OEM_24              = 0xEF # OEM Specific
  332.         OEM_25              = 0xF1 # OEM Specific
  333.         OEM_26              = 0xF2 # OEM Specific
  334.         OEM_27              = 0xF3 # OEM Specific
  335.         OEM_28              = 0xF4 # OEM Specific
  336.         OEM_29              = 0xF5 # OEM Specific
  337.         OEM_102             = 0xE2 # Angle Bracket or Backslash on RT-102 Keyboards
  338.         OEM_CLEAR           = 0xFE # Clear Key
  339.         #--------------------------------------------------------------------------
  340.         # * Declare Module Variables
  341.         #--------------------------------------------------------------------------
  342.         # Create string for unpacking input
  343.         @unpack_string = 'b'*256
  344.         # Generate blank input arrays
  345.         @last_array = '0'*256
  346.         @press = Array.new(256, false)
  347.         @trigger = Array.new(256, false)
  348.         @repeat = Array.new(256, false)
  349.         @release = Array.new(256, false)
  350.         # Generate blank counter array
  351.         @repeat_counter = Array.new(256, 0)
  352.         # Declare keyboard API
  353.         @getKeyboardState = Win32API.new('user32', 'GetKeyboardState', ['P'], 'V')
  354.         @getAsyncKeyState = Win32API.new('user32', 'GetAsyncKeyState', 'i', 'i')
  355.         # Call current keyboard state
  356.         @getKeyboardState.call(@last_array)
  357.         # Set previous keyboard state
  358.         @last_array = @last_array.unpack(@unpack_string)
  359.         # Cycle through keys
  360.         for i in [email]0...@last_array.size[/email]
  361.                 # Set pressed key state
  362.                 @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  363.         end
  364.         #--------------------------------------------------------------------------
  365.         # * Frame Update
  366.         #--------------------------------------------------------------------------
  367.         def self.update
  368.                 # Clear input arrays
  369.                 @trigger = Array.new(256, false)
  370.                 @repeat = Array.new(256, false)
  371.                 @release = Array.new(256, false)
  372.                 # create blank input array
  373.                 array = '0'*256
  374.                 # Call current keyboard state
  375.                 @getKeyboardState.call(array)
  376.                 # Unpack key array
  377.                 array = array.unpack(@unpack_string)
  378.                 # Cycle through all keys
  379.                 for i in 0...array.size
  380.                         # If the current key state does not match the previous state
  381.                         if array[i] != @last_array[i]
  382.                                 # Set current key state
  383.                                 @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  384.                                 # If the repeat counter is at 0
  385.                                 if @repeat_counter[i] <= 0 && @press[i]
  386.                                         # Set the key to repeat
  387.                                         @repeat[i] = true
  388.                                         # Set the repeat counter to 15 frames
  389.                                         @repeat_counter[i] = 15
  390.                                 end
  391.                                 # If the key is not being pressed
  392.                                 if !@press[i]
  393.                                         # Set the key to released
  394.                                         @release[i] = true
  395.                                         # If the key is being pressed
  396.                                 else
  397.                                         # Set the key to triggered
  398.                                         @trigger[i] = true
  399.                                 end
  400.                                 # If the key state is the same
  401.                         else
  402.                                 # If the key is set to pressed
  403.                                 if @press[i] == true
  404.                                         # Set the current key state
  405.                                         @press[i] = @getAsyncKeyState.call(i) == 0 ? false : true
  406.                                         # Set the key to released if it is no longer being pressed
  407.                                         @release[i] = true if !@press[i]
  408.                                 end
  409.                                 # If the repeat counter is greater than 0 and the key is pressed
  410.                                 if @repeat_counter[i] > 0 && @press[i] == true
  411.                                         # Cycle the repeat counter down one frame
  412.                                         @repeat_counter[i] -= 1
  413.                                         # If the repeat counter is 0 or less and the key is pressed
  414.                                 elsif @repeat_counter[i] <= 0 && @press[i] == true
  415.                                         # Set the key to repeat
  416.                                         @repeat[i] = true
  417.                                         # Set the repeat counter to 15 frames
  418.                                         @repeat_counter[i] = 3
  419.                                         # If the repeat counter does not equal 0
  420.                                 elsif @repeat_counter[i] != 0
  421.                                         # Set the repeat counter to 0
  422.                                         @repeat_counter[i] = 0
  423.                                 end
  424.                         end
  425.                 end
  426.                 # Set the previous keyboard state
  427.                 @last_array = array
  428.         end
  429.         #--------------------------------------------------------------------------
  430.         # * Get Key Pressed State
  431.         #     key : key index
  432.         #--------------------------------------------------------------------------
  433.         def self.press?(key)
  434.                 # Return key pressed state
  435.                 return @press[key]
  436.         end
  437.         #--------------------------------------------------------------------------
  438.         # * Get Key Triggered State
  439.         #     key : key index
  440.         #--------------------------------------------------------------------------
  441.         def self.trigger?(key)
  442.                 # Return key triggered state
  443.                 return @trigger[key]
  444.         end
  445.         #--------------------------------------------------------------------------
  446.         # * Get Key Repeated State
  447.         #     key : key index
  448.         #--------------------------------------------------------------------------
  449.         def self.repeat?(key)
  450.                 # Return key repeated state
  451.                 return @repeat[key]
  452.         end
  453.         #--------------------------------------------------------------------------
  454.         # * Get Key Released State
  455.         #     key : key index
  456.         #--------------------------------------------------------------------------
  457.         def self.release?(key)
  458.                 # Return key released state
  459.                 return @release[key]
  460.         end
  461. end

  462. #==============================================================================
  463. # ** Input
  464. #------------------------------------------------------------------------------
  465. #  This module performs key input processing
  466. #==============================================================================

  467. module Input
  468.         # Add class data
  469.         class << self
  470.                 #------------------------------------------------------------------------
  471.                 # * Alias Methods
  472.                 #------------------------------------------------------------------------
  473.                 alias glitch_input_keys_update update
  474.                 #------------------------------------------------------------------------
  475.                 # * Frame Update
  476.                 #------------------------------------------------------------------------
  477.                 def update
  478.                         # Call original method
  479.                         glitch_input_keys_update
  480.                         # Update Keys module
  481.                         Keys.update
  482.                 end
  483.         end
  484.        
  485.         def self.press?(sym)
  486.                 case sym
  487.                 when :UP
  488.                         up?(:press?)
  489.                 when :DOWN
  490.                         down?(:press?)
  491.                 when :LEFT
  492.                         left?(:press?)
  493.                 when :RIGHT
  494.                         right?(:press?)
  495.                 when :L
  496.                         l?(:press?)
  497.                 when :R
  498.                         r?(:press?)
  499.                 when :A
  500.                         a?(:press?)
  501.                 when :B
  502.                         b?(:press?)
  503.                 when :C
  504.                         c?(:press?)
  505.                 end                               
  506.         end
  507.        
  508.         def self.trigger?(sym)
  509.                 case sym
  510.                 when :UP
  511.                         up?(:trigger?)
  512.                 when :DOWN
  513.                         down?(:trigger?)
  514.                 when :LEFT
  515.                         left?(:trigger?)
  516.                 when :RIGHT
  517.                         right?(:trigger?)
  518.                 when :L
  519.                         l?(:trigger?)
  520.                 when :R
  521.                         r?(:trigger?)
  522.                 when :A
  523.                         a?(:trigger?)
  524.                 when :B
  525.                         b?(:trigger?)
  526.                 when :C
  527.                         c?(:trigger?)                                       
  528.                 end                                       
  529.         end
  530.        
  531.         def self.repeat?(sym)
  532.                 case sym
  533.                 when :UP
  534.                         up?(:repeat?)
  535.                 when :DOWN
  536.                         down?(:repeat?)
  537.                 when :LEFT
  538.                         left?(:repeat?)
  539.                 when :RIGHT
  540.                         right?(:repeat?)
  541.                 when :L
  542.                         l?(:repeat?)
  543.                 when :R
  544.                         r?(:repeat?)
  545.                 when :A
  546.                         a?(:repeat?)
  547.                 when :B
  548.                         b?(:repeat?)
  549.                 when :C
  550.                         c?(:repeat?)                                                       
  551.                 end                                       
  552.         end               
  553.        
  554.         def self.dir4
  555.                 case
  556.                 when down?(:press?)
  557.                         2
  558.                 when left?(:press?)
  559.                         4
  560.                 when right?(:press?)
  561.                         6
  562.                 when up?(:press?)
  563.                         8
  564.                 else
  565.                         0
  566.                 end                                               
  567.         end
  568.        
  569.         def self.dir8
  570.                 case
  571.                 when down?(:press?) && left?(:press?)
  572.                         1
  573.                 when down?(:press?) && up?(:press?)
  574.                         3
  575.                 when down?(:press?)
  576.                         2
  577.                 when up?(:press?) && left?(:press?)
  578.                         7
  579.                 when up?(:press?) && up?(:press?)
  580.                         9
  581.                 when up?(:press?)
  582.                         8
  583.                 when left?(:press?)
  584.                         4
  585.                 when up?(:press?)
  586.                         6
  587.                 else
  588.                         0
  589.                 end                       
  590.         end               
  591.        
  592. end

  593. #===============================================================================
复制代码

点评

搞定!谢谢!  发表于 2016-10-18 12:59
已添加注释和稍微修改脚本。请使用最新的版本。  发表于 2016-10-17 22:39
貌似只能改上和下吧  发表于 2016-10-17 21:18
脚本的最下方  发表于 2016-10-17 19:47
我说的是在哪改键位  发表于 2016-10-17 17:36

评分

参与人数 1星屑 +250 梦石 +1 收起 理由
怪蜀黍 + 250 + 1 楼主认可的解答

查看全部评分

回复 1 0

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部