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

Project1

 找回密码
 注册会员
搜索
查看: 2940|回复: 1
打印 上一主题 下一主题

[有事请教] 请问关于游戏手柄按键绑定

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3475
在线时间
1161 小时
注册时间
2016-8-9
帖子
2391

开拓者

跳转到指定楼层
1
发表于 2018-10-31 13:32:48 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
100星屑
本帖最后由 白嫩白嫩的 于 2018-11-5 17:02 编辑

2018-11-05

修改了410行的i < 6   把6改到和需要的按钮数一致,可以显示新的设置行了,但是这行并不是显示的attack,而是undefined,没有正确定义



=======================================

用了yep插件里的GamepadConfig.js  ,游戏里需要用到的上下左右,取消,确认,上翻页下翻页都有了,但是我自己增加了的游戏功能:

比如跳跃之类的新内容,我在脚本里仿照别的按钮新增了attack,结果在插件里写出来也无法体现到设置菜单内,不知道怎么回事,哎,还是怪我是个脚本盲。。。

所以跪求大神指点,比如能否给手柄按键绑定到公共事件,或者手柄按键绑定键盘的某个按键也可以,

谢谢啦

对了,所有按键都被占用了,不要说为什么不用上翻页下翻页了




JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // Yanfly Engine Plugins - Gamepad Config
  3. // GamepadConfig.js
  4. // Version: 1.01
  5. //=============================================================================
  6.  
  7. var Imported = Imported || {};
  8. Imported.GamepadConfig = true;
  9.  
  10. var Yanfly = Yanfly || {};
  11. Yanfly.GamepadConfig = Yanfly.GamepadConfig || {};
  12. Yanfly.GamepadConfig.version = 1.01;
  13.  
  14. //=============================================================================
  15. /*:
  16.  * @plugindesc v1.01 Allows players to adjust their button configuration
  17.  * for gamepads.
  18.  * @author Yanfly Engine Plugins
  19.  *
  20.  * @param Command Name
  21.  * @desc This is the option name that appears in the main menu.
  22.  * @default Gamepad Config
  23.  *
  24.  * @param Button Name
  25.  * @desc This is how a button name will appear in the config menu.
  26.  * @default Button %1
  27.  *
  28.  * @param OK Button
  29.  * @desc This is the command name for the OK button.
  30.  * @default OK / Talk
  31.  *
  32.  * @param OK Help
  33.  * @desc This is the help description for the OK button.
  34.  * @default Used to accept menu actions and talk to people.
  35.  *
  36.  * @param Cancel Button
  37.  * @desc Cancel Button
  38.  * @desc This is the command name for the Cancel button.
  39.  * @default Cancel
  40.  *
  41.  * @param Cancel Help
  42.  * @desc This is the help description for the Cancel button.
  43.  * @default Used to cancel menu actions.
  44.  *
  45.  * @param Shift Button
  46.  * @desc This is the command name for the Shift button.
  47.  * @default Dash
  48.  *
  49.  * @param Shift Help
  50.  * @desc This is the help description for the Shift button.
  51.  * @default Hold this button to dash on the field.
  52.  *
  53.  * @param Menu Button
  54.  * @desc This is the command name for the Menu button.
  55.  * @default Menu
  56.  *
  57.  * @param Menu Help
  58.  * @desc This is the help description for the Menu button.
  59.  * @default Access the Main Menu from the field.
  60.  *
  61.  * @param PageUp Button
  62.  * @desc This is the command name for the Page Up button.
  63.  * @default Page Up
  64.  *
  65.  * @param PageUp Help
  66.  * @desc This is the help description for the Page Up button.
  67.  * @default Use it to quickly scroll up menus.
  68.  *
  69.  * @param PageDown Button
  70.  * @desc This is the command name for the Page Down button.
  71.  * @default Page Down
  72.  *
  73.  * @param PageDown Help
  74.  * @desc This is the help description for the Page Down button.
  75.  * @default Use it to quickly scroll down menus.
  76.  *
  77.  * @param Reset Default
  78.  * @desc This is the command name to reset the config to default.
  79.  * @default Reset to Default
  80.  *
  81.  * @param Reset Help
  82.  * @desc This is the help description for the Reset button.
  83.  * @default Returns your controller to default settings.
  84.  *
  85.  * @param Finish Config
  86.  * @desc This is the command name for the finish button.
  87.  * @default Finish Configuration
  88.  *
  89.  * @param Finish Help
  90.  * @desc This is the help description for the Finish button.
  91.  * @default Are you done configuring your gamepad?
  92.  *
  93.  * @param Attack Button
  94.  * @desc This is the command name for the Attack button.
  95.  * @default Attack
  96.  *
  97.  * @param Attack Help
  98.  * @desc This is the help description for the Attack button.
  99.  * @default Used to Attack.
  100.  *
  101.  * @help
  102.  * Adds a "Gamepad Config" option to the Options Menu if a gamepad is detected.
  103.  * Players can then adjust the button configuration to their liking and it will
  104.  * be loaded automatically each time they play the game. Keep in mind that if
  105.  * at any point where a Gamepad is not detected inside of the Option or Gamepad
  106.  * Config menu, the game will automatically eject the player out the prevent
  107.  * the player from being locked inside.
  108.  *
  109.  * ============================================================================
  110.  * Options Core Settings - Adding the New Options
  111.  * ============================================================================
  112.  *
  113.  * If you are using YEP_OptionsCore.js, you can add a new Option using this
  114.  * plugin. Here's the following code/parameter settings you can use with it.
  115.  *
  116.  * ---------
  117.  * Settings:
  118.  * ---------
  119.  *
  120.  * Name:
  121.  * \i[83]Gamepad Config
  122.  *
  123.  * Help Description:
  124.  * Configure the game's gamepad settings.
  125.  *
  126.  * Symbol:
  127.  * gamepadConfig
  128.  *
  129.  * Show/Hide:
  130.  * if (Imported.GamepadConfig && Input.isControllerConnected()) {
  131.  *   show = !Utils.isMobileDevice();
  132.  * } else {
  133.  *   show = false;
  134.  * }
  135.  *
  136.  * Enable:
  137.  * enabled = true;
  138.  *
  139.  * Ext:
  140.  * ext = 0;
  141.  *
  142.  * ----------
  143.  * Functions:
  144.  * ----------
  145.  *
  146.  * Make Option Code:
  147.  * this.addCommand(name, symbol, enabled, ext);
  148.  *
  149.  * Draw Option Code:
  150.  * var rect = this.itemRectForText(index);
  151.  * var statusWidth = this.statusWidth();
  152.  * var titleWidth = rect.width - statusWidth;
  153.  * this.resetTextColor();
  154.  * this.changePaintOpacity(this.isCommandEnabled(index));
  155.  * this.drawOptionsName(index);
  156.  *
  157.  * Process OK Code:
  158.  * this.playOkSound();
  159.  * SceneManager.push(Scene_GamepadConfig);
  160.  *
  161.  * Cursor Right Code:
  162.  * // Empty. Provided by this plugin.
  163.  *
  164.  * Cursor Left Code:
  165.  * // Empty. Provided by this plugin.
  166.  *
  167.  * Default Config Code:
  168.  * // Empty. Provided by this plugin.
  169.  *
  170.  * Save Config Code:
  171.  * // Empty. Provided by this plugin.
  172.  *
  173.  * Load Config Code:
  174.  * // Empty. Provided by this plugin.
  175.  *
  176.  * ============================================================================
  177.  * Changelog
  178.  * ============================================================================
  179.  *
  180.  * Version 1.01:
  181.  * - Compatibility update with YEP_OptionsCore.js!
  182.  *
  183.  * Version 1.00:
  184.  * - Finished Plugin!
  185.  */
  186. //=============================================================================
  187.  
  188. //=============================================================================
  189. // Parameter Variables
  190. //=============================================================================
  191.  
  192. Yanfly.Parameters = PluginManager.parameters('GamepadConfig');
  193. Yanfly.Param = Yanfly.Param || {};
  194.  
  195. Yanfly.Param.GamepadConfigName = String(Yanfly.Parameters['Command Name']);
  196. Yanfly.Param.GamepadConfigButton = String(Yanfly.Parameters['Button Name']);
  197. Yanfly.Param.GamepadConfigOkTx = String(Yanfly.Parameters['OK Button']);
  198. Yanfly.Param.GamepadConfigOkHelp = String(Yanfly.Parameters['OK Help']);
  199. Yanfly.Param.GamepadConfigCancelTx = String(Yanfly.Parameters['Cancel Button']);
  200. Yanfly.Param.GamepadConfigCancelHelp = String(Yanfly.Parameters['Cancel Help']);
  201. Yanfly.Param.GamepadConfigShiftTx = String(Yanfly.Parameters['Shift Button']);
  202. Yanfly.Param.GamepadConfigShiftHelp = String(Yanfly.Parameters['Shift Help']);
  203. Yanfly.Param.GamepadConfigMenuTx = String(Yanfly.Parameters['Menu Button']);
  204. Yanfly.Param.GamepadConfigMenuHelp = String(Yanfly.Parameters['Menu Help']);
  205. Yanfly.Param.GamepadConfigPgUpTx = String(Yanfly.Parameters['PageUp Button']);
  206. Yanfly.Param.GamepadConfigPgUpHelp = String(Yanfly.Parameters['PageUp Help']);
  207. Yanfly.Param.GamepadConfigPgDnTx = String(Yanfly.Parameters['PageDown Button']);
  208. Yanfly.Param.GamepadConfigPgDnHelp = String(Yanfly.Parameters['PageDown Help']);
  209. Yanfly.Param.GamepadConfigResetTx = String(Yanfly.Parameters['Reset Default']);
  210. Yanfly.Param.GamepadConfigResetHelp = String(Yanfly.Parameters['Reset Help']);
  211. Yanfly.Param.GamepadConfigFinishTx = String(Yanfly.Parameters['Finish Config']);
  212. Yanfly.Param.GamepadConfigFinishHelp = String(Yanfly.Parameters['Finish Help']);
  213. Yanfly.Param.GamepadConfigAttackTx = String(Yanfly.Parameters['Attack Button']);
  214. Yanfly.Param.GamepadConfigAttackHelp = String(Yanfly.Parameters['Attack Help']);
  215.  
  216. //=============================================================================
  217. // Input
  218. //=============================================================================
  219.  
  220. Input.getPressedGamepadButton = function() {
  221.         if (Yanfly.Param.GamepadTimer > 0) {
  222.                 Yanfly.Param.GamepadTimer -= 1;
  223.                 return -1;
  224.         }
  225.         if (navigator.getGamepads) {
  226.                 var gamepads = navigator.getGamepads();
  227.                 if (gamepads) {
  228.                         for (var i = 0; i < gamepads.length; i++) {
  229.                                 var gamepad = gamepads[i];
  230.                                 if (gamepad && gamepad.connected) {
  231.                                         return this.gamepadButtonId(gamepad);
  232.                                 }
  233.                         }
  234.                 }
  235.   }
  236.         return -1;
  237. };
  238.  
  239. Input.gamepadButtonId = function(gamepad) {
  240.   var buttons = gamepad.buttons;
  241.   for (var i = 0; i < buttons.length; i++) {
  242.     if (buttons[i].pressed) return i;
  243.   }
  244.         return -1;
  245. };
  246.  
  247. Input.getGamepadButton = function(type) {
  248.         for (var i = 0; i < 12; ++i) {
  249.                 if (Input.gamepadMapper[i] === type) return i;
  250.         }
  251.         return null;
  252. };
  253.  
  254. Input.isControllerConnected = function() {
  255.         if (navigator.getGamepads) {
  256.                 var gamepads = navigator.getGamepads();
  257.                 if (gamepads) {
  258.                         for (var i = 0; i < gamepads.length; i++) {
  259.                                 var gamepad = gamepads[i];
  260.                                 if (gamepad && gamepad.connected) return true;
  261.                         }
  262.                 }
  263.         }
  264.         return false;
  265. };
  266.  
  267. //=============================================================================
  268. // ConfigManager
  269. //=============================================================================
  270.  
  271. ConfigManager.gamepadInput = {
  272.         0: 'ok',
  273.         1: 'cancel',
  274.         2: 'shift',
  275.         3: 'menu',
  276.         4: 'pageup',
  277.         5: 'pagedown',
  278.         12: 'up',
  279.         13: 'down',
  280.         14: 'left',
  281.         15: 'right',
  282.         9: 'attack',
  283. };
  284.  
  285. Yanfly.GamepadConfig.ConfigManager_makeData = ConfigManager.makeData;
  286. ConfigManager.makeData = function() {
  287.   var config = Yanfly.GamepadConfig.ConfigManager_makeData.call(this);
  288.         config.gamepadInput = this.gamepadInput;
  289.         return config;
  290. };
  291.  
  292. Yanfly.GamepadConfig.ConfigManager_applyData = ConfigManager.applyData;
  293. ConfigManager.applyData = function(config) {
  294.   Yanfly.GamepadConfig.ConfigManager_applyData.call(this, config);
  295.         this.gamepadInput = this.readGamepadConfig(config, 'gamepadInput');
  296.         this.applyGamepadConfig();
  297. };
  298.  
  299. ConfigManager.applyGamepadConfig = function() {
  300.         Input.gamepadMapper = this.gamepadInput;
  301.         Input.update();
  302.         Input.clear();
  303. };
  304.  
  305. ConfigManager.readGamepadConfig = function(config, name) {
  306.     var value = config[name];
  307.     if (value !== undefined) {
  308.         return value;
  309.     } else {
  310.         return {
  311.                                         0: 'ok',
  312.                                         1: 'cancel',
  313.                                         2: 'shift',
  314.                                         3: 'menu',
  315.                                         4: 'pageup',
  316.                                         5: 'pagedown',
  317.                                         12: 'up',
  318.                                         13: 'down',
  319.                                         14: 'left',
  320.                                         15: 'right',
  321.                                         9: 'attack',
  322.                                 };
  323.     }
  324. };
  325.  
  326. //=============================================================================
  327. // Window_Options
  328. //=============================================================================
  329.  
  330. Yanfly.GamepadConfig.Window_Options_addGeneralOptions =
  331.         Window_Options.prototype.addGeneralOptions;
  332. Window_Options.prototype.addGeneralOptions = function() {
  333.   Yanfly.GamepadConfig.Window_Options_addGeneralOptions.call(this);
  334.   if (!Imported.YEP_OptionsCore) this.addGameConfigCommand();
  335. };
  336.  
  337. Window_Options.prototype.addGameConfigCommand = function() {
  338.         if (Input.isControllerConnected()) {
  339.                 this.addCommand(Yanfly.Param.GamepadConfigName, 'gamepadConfig', true);
  340.                 this._addedController = true;
  341.         }
  342. };
  343.  
  344. Yanfly.GamepadConfig.Window_Options_update =
  345.         Window_Options.prototype.update;
  346. Window_Options.prototype.update = function() {
  347.         Yanfly.GamepadConfig.Window_Options_update.call(this);
  348.         if (this._addedController && !Input.isControllerConnected()) {
  349.                 this.refresh();
  350.                 this.height = this.windowHeight();
  351.                 this.updatePlacement();
  352.         }
  353. };
  354.  
  355. if (!Imported.YEP_OptionsCore) {
  356.  
  357. Yanfly.GamepadConfig.Window_Options_drawItem =
  358.         Window_Options.prototype.drawItem;
  359. Window_Options.prototype.drawItem = function(index) {
  360.     if (this.commandSymbol(index) === 'gamepadConfig') {
  361.                         var rect = this.itemRectForText(index);
  362.                         var text = this.commandName(index);
  363.             this.resetTextColor();
  364.             this.changePaintOpacity(this.isCommandEnabled(index));
  365.             this.drawText(text, rect.x, rect.y, rect.width, 'left');
  366.                 } else {
  367.                         Yanfly.GamepadConfig.Window_Options_drawItem.call(this, index);
  368.                 }
  369. };
  370.  
  371. Yanfly.GamepadConfig.Window_Options_processOk =
  372.         Window_Options.prototype.processOk;
  373. Window_Options.prototype.processOk = function() {
  374.   if (this.commandSymbol(this.index()) === 'gamepadConfig') {
  375.                 Window_Command.prototype.processOk.call(this);
  376.         } else {
  377.                 Yanfly.GamepadConfig.Window_Options_processOk.call(this);
  378.         }
  379. };
  380.  
  381. }; // Imported.YEP_OptionsCore
  382.  
  383.  
  384. //=============================================================================
  385. // Window_GamepadConfig
  386. //=============================================================================
  387.  
  388. function Window_GamepadConfig() {
  389.     this.initialize.apply(this, arguments);
  390. }
  391.  
  392. Window_GamepadConfig.prototype = Object.create(Window_Command.prototype);
  393. Window_GamepadConfig.prototype.constructor = Window_GamepadConfig;
  394.  
  395. Window_GamepadConfig.prototype.initialize = function(helpWindow) {
  396.         var wy = helpWindow.height;
  397.         Window_Command.prototype.initialize.call(this, 0, wy);
  398.   this.setHelpWindow(helpWindow);
  399.         this.height = Graphics.boxHeight - wy;
  400.         this.refresh();
  401.         this.activate();
  402.         this.select(0);
  403. };
  404.  
  405. Window_GamepadConfig.prototype.windowWidth = function() {
  406.     return Graphics.boxWidth;
  407. };
  408.  
  409. Window_GamepadConfig.prototype.makeCommandList = function(index) {
  410.         for (var i = 0; i < 6; ++i) {
  411.                 var text = this.getButtonTypeText(i);
  412.                 this.addCommand(text, 'button', true);
  413.         }
  414.         this.addCommand('', 'filler', true);
  415.         this.addCommand(this.getButtonTypeText(7), 'reset', true);
  416.         this.addCommand(this.getButtonTypeText(8), 'finish', true);
  417. };
  418.  
  419. Window_GamepadConfig.prototype.drawItem = function(index) {
  420.         if (index > 5) {
  421.                 Window_Command.prototype.drawItem.call(this, index);
  422.         } else {
  423.                 var rect = this.itemRectForText(index);
  424.     var align = this.itemTextAlign();
  425.                 var ww = rect.width / 2;
  426.     this.resetTextColor();
  427.     this.changePaintOpacity(this.isCommandEnabled(index));
  428.                 this.drawText(this.commandName(index), rect.x, rect.y, ww, align);
  429.                 var text = this.getButtonConfig(index);
  430.                 this.drawText(text, rect.x + ww, rect.y, ww, align);
  431.         }
  432. };
  433.  
  434. Window_GamepadConfig.prototype.getButtonTypeText = function(index) {
  435.         if (index === 0) return Yanfly.Param.GamepadConfigOkTx;
  436.         if (index === 1) return Yanfly.Param.GamepadConfigCancelTx;
  437.         if (index === 2) return Yanfly.Param.GamepadConfigShiftTx;
  438.         if (index === 3) return Yanfly.Param.GamepadConfigMenuTx;
  439.         if (index === 4) return Yanfly.Param.GamepadConfigPgUpTx;
  440.         if (index === 5) return Yanfly.Param.GamepadConfigPgDnTx;
  441.         if (index === 7) return Yanfly.Param.GamepadConfigResetTx;
  442.         if (index === 8) return Yanfly.Param.GamepadConfigFinishTx;
  443.         if (index === 9) return Yanfly.Param.GamepadConfigAttackTx;
  444.         return '';
  445. };
  446.  
  447. Window_GamepadConfig.prototype.getButtonConfig = function(index) {
  448.         if (index > 20) return '';
  449.         var key = this.getButtonKey(index);
  450.         var button = Input.getGamepadButton(key);
  451.   return Yanfly.Param.GamepadConfigButton.format(button);
  452. };
  453.  
  454. Window_GamepadConfig.prototype.getButtonKey = function(index) {
  455.         if (index === 0) return 'ok';
  456.         if (index === 1) return 'cancel';
  457.         if (index === 2) return 'shift';
  458.         if (index === 3) return 'menu';
  459.         if (index === 4) return 'pageup';
  460.         if (index === 5) return 'pagedown';
  461.         if (index === 9) return 'Attack';
  462. };
  463.  
  464. Window_GamepadConfig.prototype.itemTextAlign = function() {
  465.     return 'center';
  466. };
  467.  
  468. Window_GamepadConfig.prototype.clearButtonConfig = function(index) {
  469.     var rect = this.itemRectForText(index);
  470.                 rect.x += rect.width / 2;
  471.                 rect.width /= 2;
  472.                 this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  473. };
  474.  
  475. Window_GamepadConfig.prototype.updateHelp = function() {
  476.     if (!this._helpWindow) return;
  477.                 switch (this.index()) {
  478.                 case 0:
  479.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigOkHelp);
  480.                         break;
  481.                 case 1:
  482.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigCancelHelp);
  483.                         break;
  484.                 case 2:
  485.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigShiftHelp);
  486.                         break;
  487.                 case 3:
  488.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigMenuHelp);
  489.                         break;
  490.                 case 4:
  491.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigPgUpHelp);
  492.                         break;
  493.                 case 5:
  494.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigPgDnHelp);
  495.                         break;
  496.                 case 7:
  497.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigResetHelp);
  498.                         break;
  499.                 case 8:
  500.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigFinishHelp);
  501.                         break;
  502.                 case 9:
  503.                         this._helpWindow.setText(Yanfly.Param.GamepadConfigAttackHelp);
  504.                         break;
  505.                 default:
  506.                         this._helpWindow.clear();
  507.                         break;
  508.                 }
  509. };
  510.  
  511. //=============================================================================
  512. // Scene_Options
  513. //=============================================================================
  514.  
  515. Yanfly.GamepadConfig.Scene_Options_createOptionsWindow =
  516.         Scene_Options.prototype.createOptionsWindow;
  517. Scene_Options.prototype.createOptionsWindow = function() {
  518.   Yanfly.GamepadConfig.Scene_Options_createOptionsWindow.call(this);
  519.         this._optionsWindow.setHandler('gamepadConfig',
  520.                 this.commandGamepadConfig.bind(this));
  521. };
  522.  
  523. Scene_Options.prototype.commandGamepadConfig = function() {
  524.         SceneManager.push(Scene_GamepadConfig);
  525. };
  526.  
  527. //=============================================================================
  528. // Scene_GamepadConfig
  529. //=============================================================================
  530.  
  531. function Scene_GamepadConfig() {
  532.   this.initialize.apply(this, arguments);
  533. }
  534.  
  535. Scene_GamepadConfig.prototype = Object.create(Scene_MenuBase.prototype);
  536. Scene_GamepadConfig.prototype.constructor = Scene_GamepadConfig;
  537.  
  538. Scene_GamepadConfig.prototype.initialize = function() {
  539.   Scene_MenuBase.prototype.initialize.call(this);
  540. };
  541.  
  542. Scene_GamepadConfig.prototype.create = function() {
  543.   Scene_MenuBase.prototype.create.call(this);
  544.   this.createHelpWindow();
  545.         this.createGamepadConfigWindow();
  546. };
  547.  
  548. Scene_GamepadConfig.prototype.terminate = function() {
  549.   Scene_MenuBase.prototype.terminate.call(this);
  550.   ConfigManager.save();
  551. };
  552.  
  553. Scene_GamepadConfig.prototype.update = function() {
  554.   Scene_MenuBase.prototype.update.call(this);
  555.         this.updateAttachedController();
  556.         this.updateButtonConfig();
  557.         this.updateAfterConfig();
  558. };
  559.  
  560. Scene_GamepadConfig.prototype.updateAttachedController = function() {
  561.         if (Input.isControllerConnected()) return;
  562.         this.popScene();
  563. };
  564.  
  565. Scene_GamepadConfig.prototype.createGamepadConfigWindow = function() {
  566.         this._configWindow = new Window_GamepadConfig(this._helpWindow);
  567.         this._configWindow.setHandler('button', this.commandButton.bind(this));
  568.         this._configWindow.setHandler('reset', this.commandReset.bind(this));
  569.         this._configWindow.setHandler('finish', this.popScene.bind(this));
  570.         this.addWindow(this._configWindow);
  571. };
  572.  
  573. Scene_GamepadConfig.prototype.commandButton = function() {
  574.         var index = this._configWindow.index();
  575.         this._configWindow.clearButtonConfig(index);
  576.         this._configEnabled = true;
  577.         Yanfly.Param.GamepadTimer = 12;
  578. };
  579.  
  580. Scene_GamepadConfig.prototype.commandReset = function() {
  581.         ConfigManager.gamepadInput = {
  582.                 0: 'ok',
  583.                 1: 'cancel',
  584.                 2: 'shift',
  585.                 3: 'menu',
  586.                 4: 'pageup',
  587.                 5: 'pagedown',
  588.                 12: 'up',
  589.                 13: 'down',
  590.                 14: 'left',
  591.                 15: 'right',
  592.                 9: 'attack',
  593.         };
  594.         ConfigManager.applyGamepadConfig();
  595.         this.refreshWindows();
  596. };
  597.  
  598. Scene_GamepadConfig.prototype.refreshWindows = function() {
  599.         this._configWindow.refresh();
  600.         this._configWindow.activate();
  601.         ConfigManager.save();
  602. };
  603.  
  604. Scene_GamepadConfig.prototype.updateButtonConfig = function() {
  605.         if (!this._configEnabled) return;
  606.         var buttonId = Input.getPressedGamepadButton();
  607.         if (buttonId > 20) return;
  608.         if (buttonId >= 0) this.applyButtonConfig(buttonId);
  609. };
  610.  
  611. Scene_GamepadConfig.prototype.applyButtonConfig = function(buttonId) {
  612.         this._configEnabled = false;
  613.         var index = this._configWindow.index();
  614.         var newConfig = this._configWindow.getButtonKey(index);
  615.         var formerConfig = Input.gamepadMapper[buttonId];
  616.         var formerButton = Input.getGamepadButton(newConfig);
  617.         ConfigManager.gamepadInput[buttonId] = newConfig;
  618.         ConfigManager.gamepadInput[formerButton] = formerConfig;
  619.         ConfigManager.applyGamepadConfig();
  620.         this._configTimer = 12;
  621. };
  622.  
  623. Scene_GamepadConfig.prototype.updateAfterConfig = function() {
  624.         if (!this._configTimer) return;
  625.         if (--this._configTimer > 0) return;
  626.         SoundManager.playEquip();
  627.         this.refreshWindows();
  628. };
  629.  
  630. //=============================================================================
  631. // End of File
  632. //=============================================================================

酸酸甜甜就④哇噢

Lv3.寻梦者

梦石
0
星屑
3475
在线时间
1161 小时
注册时间
2016-8-9
帖子
2391

开拓者

2
 楼主| 发表于 2018-11-8 01:04:07 | 只看该作者
自己摸索完成了,不用这个插件了,直接调用rpgcore的函数就可以了
酸酸甜甜就④哇噢
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-8 08:12

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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