查看: 16310|回复: 20

[有事请教] 虚拟按键插件

[复制链接]
梦石
0
星屑
626
在线时间
300 小时
注册时间
2018-7-28
回帖
160
发表于 2019-5-1 22:45:37 | 显示全部楼层 |阅读模式
悬赏70星屑已解决
求大佬推荐好用的虚拟按键插件。

图片上是玩的一款别人做的游戏。他的按键可以随时切换按键和触屏模式。

并且可以在菜单和战斗界面使用。and 在是用按键是触屏就不会生效。

我自己找了好几个。但是都是效果都不太好。(可能这些要自己改代码)

我想的要求就是,能和上面我说的一样当然最好,不能我就想弄个

全程按键操作,并且触屏无效那种。

求大佬帮忙

Screenshot_2019-05-01-22-32-12_WPS图片_WPS图片_WPS图片.jpg
Screenshot_2019-05-01-22-32-27_WPS图片.png

最佳答案

查看完整内容

建立: 該設置需要在項目的img文件夾中創建一個新文件夾。 此文件夾必須命名為“mobileUI”。 下面是一個示例屏幕截圖。 將所有移動UI按鈕圖像放在此文件夾中,然後可以在插件參數中訪問它們。 在這帖40楼有個範例及按鍵圖象(未啓用) https://rpg.blue/thread-476413-4-1.html 啓用 点進去設定 D-pad設定 畫象 出現場景 X偏移(0最左) Y偏移〈0最上) 按鍵設定 on/off設定 ...
菜鸟一只
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2019-5-1 22:45:38 | 显示全部楼层
本帖最后由 tseyik 于 2019-5-3 20:45 编辑
清明上河図 发表于 2019-5-2 14:00
大佬。这样是什么问题。。。。


建立:
該設置需要在項目的img文件夾中創建一個新文件夾。 此文件夾必須命名為“mobileUI”。 下面是一個示例屏幕截圖。
0001.PNG
將所有移動UI按鈕圖像放在此文件夾中,然後可以在插件參數中訪問它們。


在這帖40楼有個範例及按鍵圖象(未啓用)
https://rpg.blue/thread-476413-4-1.html

啓用
0001.PNG
点進去設定
001.PNG
D-pad設定
畫象
出現場景
X偏移(0最左)
Y偏移〈0最上)
002.PNG
按鍵設定
0003.PNG
on/off設定
003.PNG

004.PNG

Capture.PNG
0002.PNG
回复

使用道具 举报

梦石
0
星屑
469
在线时间
447 小时
注册时间
2005-11-22
回帖
287
发表于 2019-5-2 00:43:29 | 显示全部楼层
回复

使用道具 举报

梦石
0
星屑
22584
在线时间
2605 小时
注册时间
2015-7-4
回帖
918
发表于 2019-5-2 09:54:43 | 显示全部楼层
这个可以在菜单、地图、战斗场景使用:
https://rpg.blue/thread-410350-1-7.html
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2019-5-2 10:36:58 | 显示全部楼层
本帖最后由 tseyik 于 2019-5-2 13:15 编辑

https://forums.rpgmakerweb.com/i ... ons-and-dpad.94196/
Virtual Buttons and DPad[pre lang="javascript"]"use strict";

/*:
* @plugindesc v1.4.0 Creates buttons on the screen for touch input
* @author Aloe Guvner
*
*
* @param dPadSettings
* @text D-Pad Settings
* @type struct<dpad>
* @desc Settings for the D-Pad.
*
* @param keyButtonSettings
* @text Key Button Settings
* @type struct<keyButton>[]
* @desc Settings for on-screen buttons that simulate key presses.
*
* @param controlButtonSettings
* @text Control Button Settings
* @type struct<controlButton>
* @desc A "toggle" button that allows players to turn the UI
* on and off.
*
* @param fadeDuration
* @text Fade Duration
* @desc Duration of hiding the buttons (number of frames)
* for the buttons to fade and un-fade.
* @default 20
*
* @param disableTouchWindows
* @text Disable Touch Selectable Windows
* @type text[]
* @desc Disable the touch input for selectable windows
* in these scenes.
* @default ["Scene_Menu"]
*
* @param disableTouchMovement
* @text Disable Touch Movement
* @type boolean
* @desc Disable touch movement on the map when a DPad is active.
* @default false
*
* @param enableDiagonalInput
* @text Enable Diagonal Input
* @type boolean
* @desc If the player touches in the corners of the D-Pad, both
* direction inputs are recorded. See info in help file.
* @default false
*
* @help
*
* //=============================================================================
* // Background:
* //=============================================================================
* This plugin focuses on improving the user interface for mobile games created
* in RPG Maker MV. This plugin allows the developer  to have virtual buttons
* on the screen that interact with touch input.
*
* This plugin allows maximum flexibility for the developer, you can add
* as many or as few buttons as you want to the screen, and you can add these buttons
* on whichever screens you would like (i.e. map, menu, credits, title, etc.).
*
* //=============================================================================
* // Functionality:
* //=============================================================================
*
* This plugin can create 3 different types of buttons:
* -Directional Pad
* --A single picture which is used for up, left, right, and down movement.
* --The picture is divided into 9 sections. The top 3 sections trigger the "up"
* input, the left 3 sections trigger the "left" input, the right 3 sections
* trigger the "right" input, and the bottom 3 section triggers the "down" input.
* --The middle section does not trigger any input.
* --The scenes that this button appears in can be defined.
* --This button is not mandatory.
*
* -Key buttons
* --These buttons can be used to represent any key. Common keys to use would be
* "ok" , "escape", "pagedown", "pageup".
* --However, these can be any key, and there can be as many or as few as the developer
* would like.
* --Additionally, the scenes that these buttons appear in can be controlled individually.
*
*
* -Control button
* --The control button, if pressed, will collapse and hide other buttons on the screen.
* --If pressed again, it will expand and show other buttons on the screen.
* --You can configure which other buttons are affected. This can allow you to create
*   a dynamic menu where pressing this button opens other buttons for "Items", "Save",
*   etc., while leaving the DPad or any other button active all of the time.
* --The scenes that this button appears in can be defined.
* --This button is not mandatory.
*
* //=============================================================================
* // Touch Input Methods:
* //=============================================================================
*
* The following methods can be chosen for any of the key buttons. The default
* method is "triggered".
*
* Triggered:
*   This input method occurs when the button is just pressed down. It occurs only
* once, in the same frame that the button was pressed.
*
* Pressed:
*   This input method occurs every frame while the button is pressed down. Any action
* that this button is doing will execute every frame (60 frames per second)
*
* Repeated:
*   This input method occurs after 24 frames from when the button is pressed, and
* then occurs every 6 frames while the button is still pressed.
*
* Long Pressed:
*   This input method occurs after 24 frames from when the button is pressed, and
* then occurs every frame while the button is still pressed.
*
* Released:
*   This input method occurs when the button is no longer being pressed.
*
* //=============================================================================
* // Setup:
* //=============================================================================
* This plugin requires a new folder to be created within the project "img" folder.
* The folder must be titled "mobileUI".
* Place all UI button images into this folder, and they can be accessed from the
* plugin parameters.
*
* //=============================================================================
* // Vibrate Parameter
* //=============================================================================
* Buttons can trigger a vibrate on the mobile device when pressed, controlled by
* a parameter.
* This parameter follows a pattern of vibrate,pause,vibrate,pause, etc.
* Separate each time interval by a comma.
* Examples:
* 200 --> vibrate for 200ms
* 100,30,100,30,100,30  --> vibrate for 100ms, pause for 30ms; repeat 2 more times
*
* Note that most devices support the Vibration API, but not all.
* Additionally, this may not work in all methods of deployment.
*
* //=============================================================================
* // Plugin Commands:
* //=============================================================================
* All plugin commands begin with MobileUI.
* All plugin commands are not case sensitive (i.e. DPad is the same as dpad)
*
* //=============================================================================
* hide: hides the specified button
* //=============================================================================
* Allowed first arguments:
* -DPad
* -Control
* -Any key button defined in the parameters
*
* Allowed second arguments:
* -instant (optional, this will hide the button instantly)
*
* Examples:
* MobileUI hide DPad
* mobileui hide Ok instant
* MobileUI hide PageDown
*
* //=============================================================================
* show: shows the specified button
* //=============================================================================
* Allowed first arguments:
* -DPad
* -Control
* -Any key button defined in the parameters
*
* Allowed second arguments:
* -instant (optional, this will show the button instantly)
*
* Examples:
* MobileUI show dpad
* mobileui show ok
* MobileUI show PageUp instant
*
* //=============================================================================
* Diagonal Movement Parameter
* //=============================================================================
*
* There is a parameter that controls whether diagonal input is recorded from the
* D-Pad. This is not a diagonal movement plugin! This parameter merely controls
* whether touching on the top left will add the input values of both "top" and
* "left" to the input state. Other diagonal movement plugins would consume these
* input values to move the character diagonally.
*
* If your game uses diagonal movement, this parameter must be on. If your game
* does not use diagonal movement, it is recommended to turn this parameter off.
*
* //=============================================================================
* Terms of Use:
* //=============================================================================
* Free for use in commercial or non-commercial projects.
* Credits required to: Aloe Guvner
*
* //=============================================================================
* Version History:
* //=============================================================================
* v1.4.0 (December 13 2018)
* --Added ability to configure which buttons are affected by the "control" button
*   Can be used to create dynamic menus.
* v1.3.1 (October 30 2018)
* --Added a parameter to control whether diagonal movement is detected as a
*   possible fix for a hard to reproduce movement bug.
* v1.3.0 (September 27 2018)
* --Added a parameter to choose to disable the normal touch input on any chosen
*   scene. The only touch input enabled on these scenes is the mobile UI.
* v1.2.3 (September 27 2018)
* --Fixed a bug where buttons that the player had chosen to hide would reappear
*   after a game message.
* v1.2.2 (September 27 2018)
* --Fixed a bug where buttons could be pressed before they were fully visible
* v1.2.1 (September 27 2018)
* --Added an "instant" feature to hide/show for smoother cutscene transitions
* v1.2.0 (August 26 2018)
* --Added ability to vibrate when button is pressed
* v1.1.0 (June 27 2018)
* --Fixed bug with awkward player movement on the DPad
* --Added ability to specify the type of touch input on key buttons
* v1.0.3 (May 14 2018)
* --Added ability to run custom code when a key button is pressed
* v1.0.2 (May 9 2018)
* --Added ability to play a sound effect when a button is pressed
* --Fixed a bug where the parameters weren't read correctly due to plugin name change
* --Fixed a bug where the control button didn't hide the dpad properly
* v1.0.1 (May 8 2018)
* --Added a version compatible with MV earlier than 1.6.0 using Babel.js
* v1.0.0 (April 17 2018)
* --Initial release
*
* //=============================================================================
* End of Help File
* //=============================================================================
*/

/*~struct~dpad:
* @param image
* @text Image
* @type file
* @dir img/mobileUI
* @desc File path for the D-Pad image
* @require 1
*
* @param activeScenes
* @text Scenes to show the D-Pad
* @type text[]
* @desc A list of scenes where the D-Pad will be active.
* Ex. Scene_Map, Scene_Title, etc.
* @default ["Scene_Title","Scene_Map"]
*
* @param x
* @text X
* @desc X position of the D-Pad. Formulas are allowed.
* (ex. Graphics.width - 96)
* @type text
* @default 0
*
* @param y
* @text Y
* @desc Y position of the D-Pad. Formulas are allowed.
* (ex. Graphics.height - 96)
* @type text
* @default 0
*
* @param soundEffect
* @text Sound Effect
* @type struct<soundEffect>
* @desc Sound Effect to play when button is pressed.
* Depending on scenario, SE might already play. Test first.
*
*/

/*~struct~keyButton:
* @param name
* @text Name
* @type text
* @desc The name of the button
*
* @param inputMethod
* @text Input Method
* @type select
* @option Triggered
* @value 0
* @option Pressed
* @value 1
* @option Repeated
* @value 2
* @option Long Pressed
* @value 3
* @option Released
* @value 4
* @desc The type of touch input that will trigger the button.
* See the help file for full descriptions of the options.
* @default 0
*
* @param inputTrigger
* @text Input Code
* @type text
* @desc The input code triggered when the button is pressed.
* ex. ok / escape / pagedown / pageup
*
* @param image
* @text Image
* @type file
* @dir img/mobileUI
* @desc File path for the button image
* @require 1
*
* @param activeScenes
* @text Scenes to show the button
* @type text[]
* @desc A list of scenes where the button will be active.
* Ex. Scene_Map, Scene_Title, etc.
* @default ["Scene_Title","Scene_Map"]
*
* @param x
* @text X
* @type text
* @desc X position of the button. Formulas are allowed.
* (ex. Graphics.width - 96)
* @default 0
*
* @param y
* @text Y
* @type text
* @desc Y position of the button. Formulas are allowed.
* (ex. Graphics.height - 96)
* @default 0
*
* @param soundEffect
* @text Sound Effect
* @type struct<soundEffect>
* @desc Sound Effect to play when button is pressed.
* Depending on scenario, SE might already play. Test first.
*
* @param customCode
* @text Custom Code
* @type note
* @desc Custom Javascript code to run on button press.
* Use the 'this' keyword to refer to the current scene.
*
* @param vibratePattern
* @text Vibrate Pattern
* @type text
* @default 0
* @desc Pattern of miliseconds to vibrate on press.
* Use 0 for no vibration. See help for more info.
*/

/*~struct~controlButton:
* @param image
* @text Image
* @type file
* @dir img/mobileUI
* @desc File path for the button image
* @require 1
*
* @param activeScenes
* @text Scenes to show the control button
* @type text[]
* @desc A list of scenes where the button will be active.
* Ex. Scene_Map, Scene_Title, etc.
* @default ["Scene_Title","Scene_Map"]
*
* @param x
* @text X
* @type text
* @desc X position of the button. Formulas are allowed.
* (ex. Graphics.width - 96)
* @default 0
*
* @param y
* @text Y
* @type text
* @desc Y position of the button. Formulas are allowed.
* (ex. Graphics.height - 96)
* @default 0
*
* @param soundEffect
* @text Sound Effect
* @type struct<soundEffect>
* @desc Sound Effect to play when button is pressed.
* Depending on scenario, SE might already play. Test first.
*
* @param buttonsToHide
* @text Buttons To Show / Hide
* @type text[]
* @desc A list of the Key Buttons to show and hide when
* this button is pressed. Leave empty to hide all.
* @default []
*
* @param hideDPad
* @text Show / Hide DPad?
* @type boolean
* @desc Controls whether the DPad is affected when
* this button is pressed.
* @default true
*
*/

/*~struct~soundEffect:
* @param name
* @text Sound Effect Name
* @type file
* @dir audio/se
* @desc Sound effect to play when the button is pressed.
* @default
* @require 1
*
* @param volume
* @text Volume
* @type number
* @min 0
* @max 100
* @desc Volume of the sound effect, in %
* Allowed values: 0% - 100%
* @default 90
*
* @param pitch
* @text Pitch
* @type number
* @min 50
* @max 150
* @desc Pitch of the sound effect, in %
* Allowed values: 50% - 150%
* @default 100
*
* @param pan
* @text Pan
* @type number
* @min -100
* @max 100
* @desc Pan of the sound effect
* Allowed values: -100 - 100
* @default 0
*
*/

(function () {
        "use strict";

        var Alias = {};
        var Parameters = {};
        //=============================================================================
        // Utils
        //=============================================================================
        // Create a utility function to parse complex parameters.
        //=============================================================================

        Utils.recursiveParse = function (param) {
                try {
                        return JSON.parse(param, function (key, value) {
                                try {
                                        return this.recursiveParse(value);
                                } catch (e) {
                                        return value;
                                }
                        }.bind(this));
                } catch (e) {
                        return param;
                }
        };

        //=============================================================================
        // Parameters
        //=============================================================================
        // Read and parse parameters into a locally scoped Parameters object.
        //=============================================================================

        Object.keys(PluginManager.parameters("ALOE_MobileUI")).forEach(function (a) {
                return Parameters[a] = Utils.recursiveParse(PluginManager.parameters("ALOE_MobileUI")[a]);
        });

        //=============================================================================
        // ImageManager
        //=============================================================================
        // Load and reserve mobile UI images.
        //=============================================================================

        ImageManager.loadMobileUI = function (filename, hue) {
                return this.loadBitmap('img/mobileUI/', filename, hue, true);
        };

        ImageManager.reserveMobileUI = function (filename, hue, reservationId) {
                return this.reserveBitmap('img/mobileUI/', filename, hue, true, reservationId);
        };

        //=============================================================================
        // Sprite_Button
        //=============================================================================
        // Sprite for the UI button(s)
        // Parent class for Sprite_DirectionalPad, Sprite_KeyButton, Sprite_ControlButton
        //=============================================================================

        function Sprite_Button() {
                this.initialize.apply(this, arguments);
        }

        Sprite_Button.prototype = Object.create(Sprite_Base.prototype);
        Sprite_Button.prototype.constructor = Sprite_Button;

        Sprite_Button.prototype.initialize = function (x, y, normalImage, soundEffect, vibratePattern) {
                Sprite_Base.prototype.initialize.call(this);
                if (normalImage) {
                        this.bitmap = ImageManager.loadMobileUI(normalImage);
                }
                if (soundEffect) {
                        this._soundEffect = soundEffect;
                }
                if (vibratePattern) {
                        if (!window.navigator.vibrate) {
                                this._vibratePattern = 0;
                        } else if (typeof vibratePattern === 'number') {
                                this._vibratePattern = vibratePattern;
                        } else {
                                this._vibratePattern = vibratePattern.split(',').map(function (num) {
                                        return parseInt(num);
                                });
                        }
                }
                if (isNaN(x)) {
                        x = eval(x);
                }
                if (isNaN(y)) {
                        y = eval(y);
                }
                this.move(x, y);
                this._start = new Point(null, null);
                this._distance = new Point(null, null);
                this._destination = new Point(null, null);
                this._velocity = new Point(null, null);
                this._origin = new Point(x, y);
                this._hiding = false;
                this._duration = Parameters["fadeDuration"];
                this.active = true;
                this.z = 5;
        };

        Sprite_Button.prototype.update = function () {
                Sprite_Base.prototype.update.call(this);
                if (this.active) {
                        this.updateTouchInput();
                }
                if (this.moving) {
                        this.updatePosition();
                }
                if (!this.active) {
                        this.updateActive();
                }
        };

        Sprite_Button.prototype.updateTouchInput = function () {};

        Sprite_Button.prototype.updateVisibility = function () {
                if (this._hiding && this.opacity > 0) {
                        this.opacity -= 255 / this._duration;
                } else if (!this._hiding && this.opacity < 255) {
                        this.opacity += 255 / this._duration;
                }
        };

        Sprite_Button.prototype.updateActive = function () {
                if (this.opacity === 255) {
                        this.active = true;
                }
        };

        Sprite_Button.prototype.updatePosition = function () {
                this.x += this._velocity.x;
                this.y += this._velocity.y;

                var currentPos = new Point(this.x, this.y);
                var currentDistance = this.absDistance(this._start, currentPos);
                if (currentDistance >= this._distance.abs) {
                        this.x = this._destination.x;
                        this.y = this._destination.y;
                        this._velocity.x = 0;
                        this._velocity.y = 0;
                        this.moving = false;
                }
        };

        Sprite_Button.prototype.hide = function () {
                this._hiding = true;
                this.active = false;
        };

        Sprite_Button.prototype.show = function () {
                this._hiding = false;
        };

        Sprite_Button.prototype.hideInstant = function () {
                this._hiding = true;
                this.opacity = 0;
                this.active = false;
        };

        Sprite_Button.prototype.showInstant = function () {
                this._hiding = false;
                this.opacity = 255;
                this.active = true;
        };

        Sprite_Button.prototype.collapse = function (x, y) {
                this._destination.x = x;
                this._destination.y = y;
                this._start.x = this.x;
                this._start.y = this.y;

                this._distance.x = this._destination.x - this._start.x;
                this._distance.y = this._destination.y - this._start.y;
                this._distance.abs = this.absDistance(this._destination, this._start);

                this._velocity.x = this._distance.x / this._duration;
                this._velocity.y = this._distance.y / this._duration;

                this.moving = true;
        };

        Sprite_Button.prototype.expand = function () {
                this._destination.x = this._origin.x;
                this._destination.y = this._origin.y;
                this._start.x = this.x;
                this._start.y = this.y;

                this._distance.x = this._destination.x - this._start.x;
                this._distance.y = this._destination.y - this._start.y;
                this._distance.abs = this.absDistance(this._destination, this._start);

                this._velocity.x = this._distance.x / this._duration;
                this._velocity.y = this._distance.y / this._duration;

                this.moving = true;
        };

        Sprite_Button.prototype.absDistance = function (pos1, pos2) {
                return Math.sqrt(Math.pow(pos1.x - pos2.x, 2) + Math.pow(pos1.y - pos2.y, 2));
        };

        //=============================================================================
        // Sprite_DirectionalPad
        //=============================================================================
        // Sprite for the Directional Pad
        //=============================================================================

        function Sprite_DirectionalPad() {
                this.initialize.apply(this, arguments);
        }

        Sprite_DirectionalPad.prototype = Object.create(Sprite_Button.prototype);
        Sprite_DirectionalPad.prototype.constructor = Sprite_DirectionalPad;

        Sprite_DirectionalPad.prototype.initialize = function (x, y, image, soundEffect) {
                Sprite_Button.prototype.initialize.call(this, x, y, image, soundEffect);
                this._lastInput = '';
                this._hiding = false;
        };

        Sprite_DirectionalPad.prototype.updateTouchInput = function () {
                this.clearLastDirection();
                if (TouchInput.isPressed()) {
                        var point = new Point(TouchInput.x, TouchInput.y);
                        if (this.containsPoint(point)) {
                                if (this._soundEffect) {
                                        AudioManager.playSe(this._soundEffect);
                                }
                                var index = this.whichIndex(point);
                                switch (index) {
                                        case 0:
                                                if (Parameters.enableDiagonalInput) {
                                                        Input._currentState["up"] = true;
                                                        Input._currentState["left"] = true;
                                                        this._lastInput = "up-left";
                                                }
                                                break;
                                        case 1:
                                                Input._currentState["up"] = true;
                                                this._lastInput = "up";
                                                break;
                                        case 2:
                                                if (Parameters.enableDiagonalInput) {
                                                        Input._currentState["right"] = true;
                                                        Input._currentState["up"] = true;
                                                        this._lastInput = "up-right";
                                                }
                                                break;
                                        case 3:
                                                Input._currentState["left"] = true;
                                                this._lastInput = "left";
                                                break;
                                        case 4:
                                                break;
                                        case 5:
                                                Input._currentState["right"] = true;
                                                this._lastInput = "right";
                                                break;
                                        case 6:
                                                if (Parameters.enableDiagonalInput) {
                                                        Input._currentState["left"] = true;
                                                        Input._currentState["down"] = true;
                                                        this._lastInput = "down-left";
                                                }
                                                break;
                                        case 7:
                                                Input._currentState["down"] = true;
                                                this._lastInput = "down";
                                                break;
                                        case 8:
                                                if (Parameters.enableDiagonalInput) {
                                                        Input._currentState["down"] = true;
                                                        Input._currentState["right"] = true;
                                                        this._lastInput = "down-right";
                                                }
                                                break;
                                        default:
                                                break;
                                }
                        }
                }
        };

        Sprite_DirectionalPad.prototype.whichIndex = function (point) {
                var index = 0;
                index += point.x - this.x > this.width / 3 ? point.x - this.x > this.width * 2 / 3 ? 2 : 1 : 0;
                index += point.y - this.y > this.height / 3 ? point.y - this.y > this.height * 2 / 3 ? 6 : 3 : 0;
                return index;
        };

        Sprite_DirectionalPad.prototype.clearLastDirection = function () {
                if (this._lastInput) {
                        this._lastInput.split("-").forEach(function (a) {
                                return Input._currentState[a] = false;
                        });
                        this._lastInput = '';
                }
        };

        //=============================================================================
        // Sprite_KeyButton
        //=============================================================================
        // Sprite for the buttons that simulate a key input (besides arrow keys).
        // Ex. "ok", "cancel", "pageup", "pagedown"
        //=============================================================================

        function Sprite_KeyButton() {
                this.initialize.apply(this, arguments);
        }

        Sprite_KeyButton.prototype = Object.create(Sprite_Button.prototype);
        Sprite_KeyButton.prototype.constructor = Sprite_KeyButton;

        Sprite_KeyButton.prototype.initialize = function (x, y, image, soundEffect, inputTrigger, customCode, vibratePattern) {
                var inputMethod = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;

                Sprite_Button.prototype.initialize.call(this, x, y, image, soundEffect, vibratePattern);
                if (inputTrigger) {
                        this._inputTrigger = inputTrigger;
                }
                if (customCode) {
                        this._customCode = customCode;
                        this._customFunction = new Function(customCode).bind(SceneManager._scene);
                }
                this._inputMethod = inputMethod;
        };

        Sprite_KeyButton.prototype.isTouchTriggered = function () {
                switch (this._inputMethod) {
                        case 0:
                                // Was just pressed
                                return TouchInput.isTriggered();
                        case 1:
                                //Currently pressed down
                                return TouchInput.isPressed();
                        case 2:
                                //Is repeated
                                return TouchInput.isRepeated();
                        case 3:
                                //Is kept pressed
                                return TouchInput.isLongPressed();
                        case 4:
                                //Was just released
                                return TouchInput.isReleased();
                        default:
                                return TouchInput.isTriggered();
                }
        };

        Sprite_KeyButton.prototype.updateTouchInput = function () {
                if (this.isTouchTriggered()) {
                        var point = new Point(TouchInput.x, TouchInput.y);
                        if (this.containsPoint(point)) {
                                if (this._soundEffect) {
                                        AudioManager.playSe(this._soundEffect);
                                }
                                if (this._vibratePattern) {
                                        window.navigator.vibrate(this._vibratePattern);
                                }
                                if (this._customFunction) {
                                        this._customFunction();
                                }
                                if (this._inputTrigger) {
                                        Input._currentState[this._inputTrigger] = true;
                                }
                        } else {
                                Input._currentState[this._inputTrigger] = false;
                        }
                } else {
                        Input._currentState[this._inputTrigger] = false;
                }
        };

        //=============================================================================
        // Sprite_ControlButton
        //=============================================================================
        // Sprite for the button that activates / deactivates all other buttons.
        //=============================================================================

        function Sprite_ControlButton() {
                this.initialize.apply(this, arguments);
        }

        Sprite_ControlButton.prototype = Object.create(Sprite_Button.prototype);
        Sprite_ControlButton.prototype.constructor = Sprite_ControlButton;

        Sprite_ControlButton.prototype.initialize = function (x, y, image, soundEffect) {
                Sprite_Button.prototype.initialize.call(this, x, y, image, soundEffect);
                this._inputTrigger = "control";
                this._buttonsHidden = false;
        };

        Sprite_ControlButton.prototype.updateTouchInput = function () {
                if (TouchInput.isTriggered()) {
                        var point = new Point(TouchInput.x, TouchInput.y);
                        if (this.containsPoint(point)) {
                                if (this._soundEffect) {
                                        AudioManager.playSe(this._soundEffect);
                                }
                                if (this._buttonsHidden) {
                                        this.showAllButtons();
                                } else {
                                        this.hideAllButtons();
                                }
                        }
                }
        };

        Sprite_ControlButton.prototype.showAllButtons = function () {
                var _this = this;

                var params = Parameters["controlButtonSettings"];
                if (params.buttonsToHide.length > 0) {
                        params.buttonsToHide.forEach(function (buttonName) {
                                if (!_this._keyButtons[buttonName]) {
                                        console.error(buttonName + " is not a key button, check your Mobile UI plugin configuration.");
                                        return;
                                }
                                _this._keyButtons[buttonName].show();
                                _this._keyButtons[buttonName].expand();
                        });
                } else {
                        Object.values(this._keyButtons).forEach(function (button) {
                                button.show();
                                button.expand();
                        });
                }
                if (params.hideDPad && this._directionalPad) {
                        this._directionalPad.show();
                        this._directionalPad.expand();
                }
                this._buttonsHidden = false;
        };

        Sprite_ControlButton.prototype.hideAllButtons = function () {
                var _this2 = this;

                var params = Parameters["controlButtonSettings"];
                if (params.buttonsToHide.length > 0) {
                        params.buttonsToHide.forEach(function (buttonName) {
                                if (!_this2._keyButtons[buttonName]) {
                                        console.error(buttonName + " is not a key button, check your Mobile UI plugin configuration.");
                                        return;
                                }
                                _this2._keyButtons[buttonName].hide();
                                _this2._keyButtons[buttonName].collapse(_this2.x, _this2.y);
                        });
                } else {
                        Object.values(this._keyButtons).forEach(function (button) {
                                button.hide();
                                button.collapse(_this2.x, _this2.y);
                        });
                }
                if (params.hideDPad && this._directionalPad) {
                        this._directionalPad.hide();
                        this._directionalPad.collapse(this.x, this.y);
                }
                this._buttonsHidden = true;
        };

        //=============================================================================
        // Scene_Base
        //=============================================================================
        // Methods to create the buttons in any scene.
        //=============================================================================

        Alias.Scene_Boot_create = Scene_Boot.prototype.create;
        Scene_Boot.prototype.create = function () {
                Alias.Scene_Boot_create.call(this);
                if (Parameters["dPadSettings"].activeScenes) {
                        Parameters["dPadSettings"].activeScenes = Parameters["dPadSettings"].activeScenes.map(function (a) {
                                return eval(a);
                        });
                }
                if (Parameters["keyButtonSettings"]) {
                        Parameters["keyButtonSettings"].forEach(function (a) {
                                return a.activeScenes = a.activeScenes.map(function (b) {
                                        return b = eval(b);
                                });
                        });
                }
                if (Parameters["controlButtonSettings"].activeScenes) {
                        Parameters["controlButtonSettings"].activeScenes = Parameters["controlButtonSettings"].activeScenes.map(function (a) {
                                return eval(a);
                        });
                }
        };

        Alias.Scene_Base_start = Scene_Base.prototype.start;
        Scene_Base.prototype.start = function () {
                Alias.Scene_Base_start.call(this);
                this.createDirPad();
                this.createKeyButtons();
                this.createControlButton();
        };

        Scene_Base.prototype.createDirPad = function () {
                var params = Parameters["dPadSettings"];
                if (params) {
                        if (params.activeScenes.length > 0 && params.activeScenes.contains(this.constructor)) {
                                var x = params.x;
                                var y = params.y;
                                var image = params.image || "";
                                var soundEffect = params.soundEffect;
                                this._directionalPad = new Sprite_DirectionalPad(x, y, image, soundEffect);

                                this.addChild(this._directionalPad);
                        }
                }
        };

        Scene_Base.prototype.createKeyButtons = function () {
                var params = Parameters["keyButtonSettings"];
                if (params) {
                        if (params.length > 0) {
                                this._keyButtons = {};
                                for (var i = 0; i < params.length; i++) {
                                        if (params.activeScenes.length > 0 && params.activeScenes.contains(this.constructor)) {
                                                var a = params;
                                                this._keyButtons[a.name.toLowerCase()] = new Sprite_KeyButton(a.x, a.y, a.image, a.soundEffect, a.inputTrigger.toLowerCase(), a.customCode, a.vibratePattern, a.inputMethod);
                                                this.addChild(this._keyButtons[a.name.toLowerCase()]);
                                        }
                                }
                        }
                }
        };

        Scene_Base.prototype.createControlButton = function () {
                var params = Parameters["controlButtonSettings"];
                if (params) {
                        if (params.activeScenes.length > 0 && params.activeScenes.contains(this.constructor)) {
                                var x = params.x;
                                var y = params.y;
                                var image = params.image || "";
                                var soundEffect = params.soundEffect;
                                this._controlButton = new Sprite_ControlButton(x, y, image, soundEffect);
                                this.addChild(this._controlButton);
                                this._controlButton._keyButtons = this._keyButtons;
                                this._controlButton._directionalPad = this._directionalPad;
                        }
                }
        };

        Scene_Base.prototype.hideMobileUI = function () {
                var _this3 = this;

                if (this._directionalPad) {
                        this._directionalPad.hide();
                }
                if (this._keyButtons) {
                        Object.keys(this._keyButtons).forEach(function (a) {
                                return _this3._keyButtons[a].hide();
                        });
                }
                if (this._controlButton) {
                        this._controlButton.hide();
                }
        };

        Scene_Base.prototype.showMobileUI = function () {
                var _this4 = this;

                if (this._directionalPad) {
                        this._directionalPad.show();
                }
                if (this._keyButtons) {
                        Object.keys(this._keyButtons).forEach(function (a) {
                                return _this4._keyButtons[a].show();
                        });
                }
                if (this._controlButton) {
                        this._controlButton.show();
                }
        };

        Alias.Scene_Base_terminate = Scene_Base.prototype.terminate;
        Scene_Base.prototype.terminate = function () {
                var _this5 = this;

                Alias.Scene_Base_terminate.call(this);
                if (this._directionalPad) {
                        this.removeChild(this._directionalPad);
                }
                if (this._keyButtons) {
                        Object.keys(this._keyButtons).forEach(function (a) {
                                return _this5.removeChild(_this5._keyButtons[a]);
                        });
                }
                if (this._controlButton) {
                        this.removeChild(this._controlButton);
                }
        };

        //=============================================================================
        // Scene_Map
        //=============================================================================
        // If map movement is disabled from the parameters, return.
        // If an active button is pressed, don't do the usual map movement.
        //=============================================================================

        Alias.Scene_Map_processMapTouch = Scene_Map.prototype.processMapTouch;
        Scene_Map.prototype.processMapTouch = function () {
                var _this6 = this;

                if (Parameters['disableTouchMovement'] && this._directionalPad && this._directionalPad.active) {
                        return;
                }
                if (TouchInput.isTriggered()) {
                        var point = new Point(TouchInput.x, TouchInput.y);
                        if (!!this._controlButton) {
                                if (this._controlButton.containsPoint(point)) {
                                        return;
                                }
                        }
                        if (this._directionalPad) {
                                if (this._directionalPad.active && this._directionalPad.containsPoint(point)) {
                                        return;
                                }
                        }
                        if (this._keyButtons) {
                                if (Object.keys(this._keyButtons).some(function (a) {
                                        return _this6._keyButtons[a].containsPoint(point);
                                })) {
                                        return;
                                }
                        }
                }
                Alias.Scene_Map_processMapTouch.call(this);
        };

        //=============================================================================
        // Window_Selectable
        //=============================================================================
        // Disable Touch Input on selectable windows if configured in the parameters.
        //=============================================================================

        Alias.Window_Selectable_processTouch = Window_Selectable.prototype.processTouch;
        Window_Selectable.prototype.processTouch = function () {
                if (Parameters['disableTouchWindows'].contains(SceneManager._scene.constructor.name)) {
                        return;
                }
                Alias.Window_Selectable_processTouch.call(this);
        };

        //=============================================================================
        // Window_Message
        //=============================================================================
        // Control UI visibility when the dialogue window is activated.
        //=============================================================================

        Alias.Window_Message_startMessage = Window_Message.prototype.startMessage;
        Window_Message.prototype.startMessage = function () {
                SceneManager._scene.hideMobileUI();
                Alias.Window_Message_startMessage.call(this);
        };

        Alias.Window_Message_terminateMessage = Window_Message.prototype.terminateMessage;
        Window_Message.prototype.terminateMessage = function () {
                Alias.Window_Message_terminateMessage.call(this);
                if (SceneManager._scene._controlButton && SceneManager._scene._controlButton._buttonsHidden) {
                        SceneManager._scene._controlButton.show();
                } else {
                        SceneManager._scene.showMobileUI();
                }
        };

        //=============================================================================
        // Game_Interpreter
        //=============================================================================
        // Plugin commands
        //=============================================================================

        Alias.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
        Game_Interpreter.prototype.pluginCommand = function (command, args) {
                Alias.Game_Interpreter_pluginCommand.call(this, command, args);
                if (command.toLowerCase() === "mobileui") {
                        var scene = SceneManager._scene;
                        switch (args[0].toLowerCase()) {
                                case "hide":
                                        switch (args[1].toLowerCase()) {
                                                case "dpad":
                                                        if (scene._directionalPad) {
                                                                if (args[2] && args[2].toLowerCase() === 'instant') {
                                                                        scene._directionalPad.hideInstant();
                                                                } else {
                                                                        scene._directionalPad.hide();
                                                                }
                                                        }
                                                        break;
                                                case "control":
                                                        if (scene._controlButton) {
                                                                if (args[2] && args[2].toLowerCase() === 'instant') {
                                                                        scene._controlButton.hideInstant();
                                                                } else {
                                                                        scene._controlButton.hide();
                                                                }
                                                        }
                                                        break;
                                                default:
                                                        if (scene._keyButtons[args[1].toLowerCase()]) {
                                                                if (args[2] && args[2].toLowerCase() === 'instant') {
                                                                        scene._keyButtons[args[1].toLowerCase()].hideInstant();
                                                                } else {
                                                                        scene._keyButtons[args[1].toLowerCase()].hide();
                                                                }
                                                        }
                                                        break;
                                        }
                                        break;
                                case "show":
                                        switch (args[1].toLowerCase()) {
                                                case "dpad":
                                                        if (scene._directionalPad) {
                                                                if (args[2] && args[2].toLowerCase() === 'instant') {
                                                                        scene._directionalPad.showInstant();
                                                                } else {
                                                                        scene._directionalPad.show();
                                                                }
                                                        }
                                                        break;
                                                case "control":
                                                        if (scene._controlButton) {
                                                                if (args[2] && args[2].toLowerCase() === 'instant') {
                                                                        scene._controlButton.showInstant();
                                                                } else {
                                                                        scene._controlButton.show();
                                                                }
                                                        }
                                                        break;
                                                default:
                                                        if (scene._keyButtons[args[1].toLowerCase()]) {
                                                                if (args[2] && args[2].toLowerCase() === 'instant') {
                                                                        scene._keyButtons[args[1].toLowerCase()].showInstant();
                                                                } else {
                                                                        scene._keyButtons[args[1].toLowerCase()].show();
                                                                }
                                                        }
                                                        break;
                                        }
                                        break;
                        }
                }
        };
})();
[/pre]


Capture.PNG
Capture2.PNG
Capture3.PNG

功能:
這個插件可以創建3種不同類型的按鈕:

1.)定向墊

    單張圖片,用於向上,向左,向右和向下移動。
    可以定義此按鈕出現的場景。
    此按鈕是可選的。

2.)按鍵

    這些按鈕可用於表示任何鍵。使用的常用鍵是“ok”,“escape”,“pagedown”,“pageup”。
    這些可以是任何密鑰,並且可以有開發人員想要的那麼多或幾個。
    此外,可以單獨控制這些按鈕出現的場景。
    您還可以編寫在按下按鈕時運行的自定義代碼!
    這可以與其他插件(如Yanfly Button Common Events)結合使用,從虛擬按鈕調用公共事件。
    您可以指定此按鈕響應的輸入類型:
        觸發:按下時執行一次(默認)
        按下:按下時執行每一幀
        重複:24幀後,按下時每6幀執行一次
        長按:24幀後,按下時執行每一幀
        發布:釋放按鈕時執行一次

3.)控制按鈕

    按下控制按鈕將折疊並隱藏屏幕上的所有其他按鈕。
    如果再次按下,它將展開並顯示屏幕上的所有其他按鈕。
    這允許玩家在使用Mobile UI按鈕或標準觸摸輸入之間做出決定。
    可以定義此按鈕出現的場景。
    此按鈕是可選的。
回复

使用道具 举报

梦石
0
星屑
626
在线时间
300 小时
注册时间
2018-7-28
回帖
160
 楼主| 发表于 2019-5-2 13:35:47 | 显示全部楼层
空山鸣涧 发表于 2019-5-2 00:43
https://rpg.blue/thread-398713-1-1.html
这个?

这个我看过,菜单那些不能用
菜鸟一只
回复

使用道具 举报

梦石
0
星屑
626
在线时间
300 小时
注册时间
2018-7-28
回帖
160
 楼主| 发表于 2019-5-2 13:36:24 | 显示全部楼层
Fan723 发表于 2019-5-2 09:54
这个可以在菜单、地图、战斗场景使用:
https://rpg.blue/thread-410350-1-7.html

用在自己的游戏里面没用啊
菜鸟一只
回复

使用道具 举报

梦石
0
星屑
626
在线时间
300 小时
注册时间
2018-7-28
回帖
160
 楼主| 发表于 2019-5-2 14:00:41 | 显示全部楼层
tseyik 发表于 2019-5-2 10:36
https://forums.rpgmakerweb.com/index.php?threads/virtual-buttons-and-dpad.94196/
[fold=Virtual Butto ...

大佬。这样是什么问题。。。。
360截图187705237255100.jpg
360截图17290503465085.jpg
菜鸟一只
回复

使用道具 举报

梦石
0
星屑
626
在线时间
300 小时
注册时间
2018-7-28
回帖
160
 楼主| 发表于 2019-5-4 18:54:52 | 显示全部楼层
tseyik 发表于 2019-5-2 19:40
建立:
該設置需要在項目的img文件夾中創建一個新文件夾。 此文件夾必須命名為“mobileUI”。 下面是一個 ...



大佬,我弄了好久还是不会 。问几个问题,

1.那个大佬插件中所用到图片,他是单独分每张还是就用你前面发的那个很多图标的那一张图片。。。

2.我百度翻译每个翻译这看了下,设置那些差不多都理解了。就是我不懂事我设置问题还是插件问题,

我不管设置没设置图片打开游戏都出现
cannot read property ‘activescenes’ of undefined(我百度翻译是  无法读取未定义的属性“activescenes”  )
。
3,不懂是不是插件问题。我是把你发的那段代码直接复制,用nopepad++打开,黏贴复制直接改格式的,
我也不知道这样对不对...........




点评

大佬,还是这个个cannot read property ‘activescenes’ of undefined错误。这个是什么插件问题还是什么啊  发表于 2019-5-4 21:22
单独分每张  发表于 2019-5-4 20:44
菜鸟一只
回复

使用道具 举报

梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2019-5-5 15:06:13 | 显示全部楼层
本帖最后由 tseyik 于 2019-5-5 15:08 编辑

你開一個新專案
Project11.zip (908.34 KB, 下载次数: 283)
然後用這個替代;mobileUI放在img文件夾
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部