查看: 1668|回复: 0

[有事请教] 插件中加入一个开关在游戏中自由操控开启或者关闭?

[复制链接]
梦石
0
星屑
6447
在线时间
1702 小时
注册时间
2018-1-16
回帖
364
发表于 2021-3-29 09:12:38 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 l734273398 于 2021-3-29 09:13 编辑

如题:大佬们有没有帮帮忙的,在这个插件中加入一个开关,使其可以在游戏中自由开启或者关闭的,万分感激啊


  1. //=============================================================================
  2. // UCHU_MobileOperation.js
  3. // Version: 1.1.4
  4. //----------------------------------------------------------------------------
  5. // Copyright (c) 2015 uchuzine
  6. // Released under the MIT license
  7. // [url]http://opensource.org/licenses/mit-license.php[/url]
  8. //=============================================================================

  9. /*:
  10. @plugindesc
  11. スマホ操作用プラグイン。横持ち/縦持ちに対応した仮想ボタン、
  12. タッチ操作の方法を追加拡張し、スマホプレイを快適にします。
  13. @author
  14. uchuzine
  15. @help
  16. UCHU_MobileOperation (Version: 1.1.4)
  17. ------------------------------------------------------------------------------
  18. ■更新履歴
  19. ------------------------------------------------------------------------------
  20. 1.1.4 2015/12/04  画面下部メッセージ表示後に下記の問題が再発する不具合を修正
  21. 1.1.3 2015/11/29  画面左上にボタンを設置した際にボタンが押せない不具合を修正
  22. 1.1.2 2015/11/24  パラメータを変更できない不具合を修正
  23. 1.1.1 2015/11/23  PC上での仮想ボタン操作時の不具合を修正
  24. 1.1.0 2015/11/17  「AnalogMove.js」使用時のアナログ移動に対応。下記説明を参照
  25. 1.0.0 2015/11/15 プラグイン公開

  26. ------------------------------------------------------------------------------
  27. ■特徴
  28. ------------------------------------------------------------------------------
  29. プラグイン作成にあたり、por Masked氏のMBS_MobileDirPad.jsを参考にしています。

  30. ○本プラグインの特徴
  31. ・ゲーム画面外(黒帯部分)にボタンを設置するため、プレイ画面に干渉しにくい
  32. ・パッドやボタンは個別に表示/非表示の切り替えが可能
  33. ・ボタンの基準点を画面四隅のいずれかに指定でき、縦持ち操作に対応可能
  34. ・方向パッドの操作性を重視し、タッチ判定領域、斜め方向の感度など調整可能
  35.  (詳細は下記の説明を参照)
  36. ・方向パッドによる移動と、デフォルトの目的地タッチによる移動を併用可能
  37. ・特定のタッチ操作、ジェスチャーによるボタン操作の拡張

  38. これらを利用し、

  39. ・仮想十字キーは使わずに、MENUボタンと決定ボタンのみ使用
  40. ・ボタンは全て使用せず、画面長押しでオート連打、画面外タッチでメニュー呼出

  41. といった使い方もできます。

  42. ------------------------------------------------------------------------------
  43. ■一部のパラメータの説明
  44. ------------------------------------------------------------------------------
  45. ▼ DPad OpelationRange(方向パッド作動領域)‥‥
  46. 方向パッド画像の表示サイズに対する、タッチ判定領域の大きさを倍率で指定します。
  47. 数値を上げても見た目は変わりませんが、画像の中心から外側に判定が広がります。
  48. 例)
  49. 「1」のとき‥‥画像のサイズがタッチ判定の大きさになる(画像の内接円の中のみ)
  50. 「2」のとき‥‥タッチ判定の大きさが縦横2倍になる(画像の外側に50%ずつ広がる)

  51. 数値を上げることで操作ミスを防ぎ、操作性を上げることができますが
  52. 上げ過ぎて他のボタン等に重なってしまわないように注意してください。

  53. ▼ DPad DiagonalRange(方向パッドの斜め方向範囲)‥‥
  54. 方向の判定は、パッド画像の対角線を境界線にして上下左右に分けていますが、
  55. この数値を上げると、対角線上をタッチしたときにその両側の方向がオンになり
  56. (「右」+「上」など)、8方向判定ができるようになります。
  57. 8方向移動のプラグインを使用している時などは、この数値を設定してください。

  58. 数値の大きさが斜め判定角度の広さとなり、「0~1」の範囲で指定します
  59. 例)
  60. 「0」のとき‥‥上下左右の4方向のみ入力可能。
  61. 「0.5」のとき‥均等8分割の8方向入力が可能。
  62. 「1」のとき‥‥「右上」「右下」「左上」「左下」の4方向入力。

  63. 数値を上げるほど、「上を押すつもりが右上になっていた」等のミスが起こるため
  64. 4方向で問題ない場合は、「0」を指定すると操作ミスが最小限になります。


  65. (var1.1.0より追加)
  66. ▼ AnalogMove(アナログ移動)‥‥
  67. サンシロ様のプラグイン「AnalogMove.js」使用時に、アナログ移動を可能にします。
  68. 方向パッドの中心からタッチ位置の距離と角度で、ドット単位の移動ができます。
  69. 使用の際はプラグインマネージャーで、先に「AnalogMove.js」を読み込み
  70. こちらのパラメータ「AnalogMove」をtrueに変えてください。
  71. ※アナログ移動使用中は、「DPad DiagonalRange」の数値は無視されます。

  72. ▼ AnalogSensitivity(入力感度)‥‥
  73. 「AnalogSensitivity」は入力感度で、数値を上げるほど
  74. 最大値(最大スピード)まで入力するのに必要な指の動きが小さくなります。
  75. 例)
  76. 「1」のとき‥‥入力判定の外端で最大値に。大きな指の移動が必要。
  77. 「DPad OpelationRange」と同じとき‥‥方向パッド画像の外端で最大値に。

  78. DPad OpelationRangeよりも大きめの数値を指定すると、入力が楽になります。
  79. (DPad OpelationRangeの初期値1.3に対し、AnalogSensitivityの初期値は1.8です)

  80. ------------------------------------------------------------------------------
  81. ■パッド、ボタン画像について
  82. ------------------------------------------------------------------------------
  83. ・画像ファイルは任意のサイズで作成可能ですが、縦横比1:1で作成してください。
  84.  表示の際は、「DPad Size」で指定したpixel数にリサイズされます。
  85.  ボタン画像も同様です。
  86. ・方向パッドのグラフィックの中心が画像の中心になるようにしてください。



  87. @param ---PC Option---
  88. @default

  89. @param PC BtnDisplay
  90. @desc PCで実行時も、仮想ボタンを表示する:true しない:false
  91. 初期値:false
  92. @default false

  93. @param PC TouchExtend
  94. @desc PCで実行時も、タッチの操作拡張を有効にする:true しない:false
  95. 初期値:true;
  96. @default true

  97. @param ---File Path---
  98. @default

  99. @param DPad Image
  100. @desc 方向パッド画像のファイルパス
  101. @default ./img/system/DirPad.png

  102. @param ActionBtn Image
  103. @desc 決定ボタン画像のファイルパス
  104. @default ./img/system/ActionButton.png

  105. @param CancelBtn Image
  106. @desc キャンセル(メニュー)ボタン画像のファイルパス
  107. @default ./img/system/CancelButton.png

  108. @param ---Button Customize---
  109. @default

  110. @param Button Opacity
  111. @desc ボタンの不透明度(0~1) 初期値:0.7
  112. @default 0.7

  113. @param Vertical BtnZoom
  114. @desc スマホ縦持ちで表示したときの全ボタンの拡大率
  115. 初期値:1.7
  116. @default 1.7

  117. @param Tablet BtnZoom
  118. @desc タブレット横持ちで表示したときの全ボタンの拡大率
  119. 初期値:0.8
  120. @default 0.8

  121. @param TabVertical BtnZoom
  122. @desc タブレット縦持ちで表示したときの全ボタンの拡大率
  123. 初期値:1.1
  124. @default 1.1

  125. @param HideButton OnMessage
  126. @desc 画面下部にメッセージ表示時、仮想ボタンの表示順位をゲーム画面の下に下げる:true そのまま:false
  127. 初期値:true
  128. @default true

  129. @param DPad Visible
  130. @desc 方向パッドを表示する:true しない:false  初期値:true
  131. @default true

  132. @param DPad Size
  133. @desc 方向パッドの大きさ(px)。 初期値:200
  134. @default 200

  135. @param DPad Margin
  136. @desc 方向パッド画像の位置。画面端からの隙間の大きさで指定。
  137. (左からの幅; 下からの幅) 初期値:10; 10
  138. @default 10; 10

  139. @param DPad Orientation
  140. @desc 方向パッドの基準位置を、左下以外に変えたい場合。
  141. left か right; top か bottom で指定。 初期値:left; bottom
  142. @default left; bottom

  143. @param DPad OpelationRange
  144. @desc 方向パッド画像に対する、タッチの作動範囲(倍率、1~)
  145. 画像の外側にタッチ判定を広げ、操作ミスを防ぐ。初期値:1.3
  146. @default 1.3

  147. @param DPad DiagonalRange
  148. @desc 方向パッド斜め方向の判定の広さ(0~1)。斜めに入りやすくする程、操作がブレやすくなる。4方向でよい場合は0に。初期値:0.3;
  149. @default 0.3

  150. @param ActionBtn Visible
  151. @desc 決定ボタンを表示する:true しない:false  初期値:true
  152. @default true

  153. @param ActionBtn Size
  154. @desc 決定ボタンの大きさ(px)。 初期値:100
  155. @default 100

  156. @param ActionBtn Margin
  157. @desc 決定ボタンの位置。画面端からの隙間の大きさで指定。
  158. (右からの幅; 下からの幅) 初期値:10; 90
  159. @default 10; 90

  160. @param ActionBtn Orientation
  161. @desc 決定ボタンの基準位置を、右下以外に変えたい場合。
  162. left か right; top か bottom で指定。 初期値:right; bottom
  163. @default right; bottom

  164. @param CancelBtn Visible
  165. @desc キャンセル(メニュー)ボタンを表示する:true しない:false
  166. 初期値:true
  167. @default true

  168. @param CancelBtn Size
  169. @desc キャンセルボタンの大きさ(px)。 初期値:100
  170. @default 100

  171. @param CancelBtn Margin
  172. @desc キャンセルボタンの位置。画面端からの隙間の大きさで指定。
  173. (右からの幅; 下からの幅) 初期値:110; 10
  174. @default 110; 10

  175. @param CancelBtn Orientation
  176. @desc キャンセルボタンの基準位置を、右下以外に変えたい場合。
  177. left か right; top か bottomで指定。 初期値:right; bottom
  178. @default right; bottom


  179. @param ---TouchInput Extend---
  180. @default

  181. @param Flick PageUp-PageDown
  182. @desc 画面上を左右にフリックすると、PageUp/PageDown操作になる。
  183. ステータス画面でキャラを切り替えたい時などに。初期値:true
  184. @default true

  185. @param HoldCanvas ActionBtn
  186. @desc 画面を長押しすると、決定ボタンを押した状態になる。
  187. 初期値:true
  188. @default true

  189. @param OutCanvas CancelBtn
  190. @desc ゲーム画面外の黒帯部分全体が、キャンセルボタン扱いになる。
  191. 初期値:false
  192. @default false

  193. @param OutCanvas ActionBtn
  194. @desc ゲーム画面外の黒帯部分全体が、決定ボタン扱いになる。
  195. 初期値:false
  196. @default false

  197. @param --!need AnalogMove.js!--
  198. @default

  199. @param Analog Move
  200. @desc [※AnalogMove.jsを先に読み込んでください]
  201. 方向パッドでアナログ移動ができるようにする。初期値:false
  202. @default false

  203. @param Analog Sensitivity
  204. @desc アナログ移動の入力感度。数値を上げると、細かい指の動きでキャラが大きく動く。
  205. 初期値:1.8
  206. @default 1.8

  207. */

  208. var Imported = Imported || {};
  209. Imported.UCHU_MobileOperation = "1.1.4";

  210. var UCHU_MobileOperation = {};

  211. (function() {
  212.     "use strict";
  213.        
  214.         //-----------------------------------------------------------------------------
  215.         // Setup
  216.        
  217.         var Parameters = PluginManager.parameters('UCHU_MobileOperation');
  218.         var PRM = PRM || {};
  219.        
  220.         PRM.url=[];
  221.         PRM.visible=[];
  222.         PRM.size=[];
  223.         PRM.pos=[];
  224.         PRM.spot=[];
  225.        
  226.         PRM.pcBtn = Boolean(Parameters["PC BtnDisplay"] === 'true' || false);
  227.         PRM.pcExt = Boolean(Parameters["PC TouchExtend"] === 'true' || false);
  228.         PRM.url[0] = String(Parameters["DPad Image"]);
  229.         PRM.url[1] = String(Parameters["ActionBtn Image"]);
  230.         PRM.url[2] = String(Parameters["CancelBtn Image"]);
  231.         PRM.opacity = Number(Parameters["Button Opacity"]);
  232.         PRM.vZoom = Number(Parameters["Vertical BtnZoom"]);
  233.         PRM.tabZoom = Number(Parameters["Tablet BtnZoom"]);
  234.         PRM.tabvZoom = Number(Parameters["TabVertical BtnZoom"]);
  235.         PRM.hideBtn = Boolean(Parameters["HideButton OnMessage"] === 'true' || false);
  236.         PRM.visible[0] = Boolean(Parameters["DPad Visible"] === 'true' || false);
  237.         PRM.size[0] = Number(Parameters["DPad Size"]);
  238.         PRM.pos[0] =Parameters["DPad Margin"].split(";");
  239.         PRM.spot[0] = Parameters["DPad Orientation"].split(";");
  240.         PRM.pad_scale = Number(Parameters["DPad OpelationRange"]);
  241.         PRM.pad_dia = Math.max(0,Math.min(1,(1-Number(Parameters["DPad DiagonalRange"]))));
  242.         PRM.visible[1] = Boolean(Parameters["ActionBtn Visible"] === 'true' || false);
  243.         PRM.size[1] = Number(Parameters["ActionBtn Size"]);
  244.         PRM.pos[1] = Parameters["ActionBtn Margin"].split(";");
  245.         PRM.spot[1] = Parameters["ActionBtn Orientation"].split(";");
  246.         PRM.visible[2] = Boolean(Parameters["CancelBtn Visible"] === 'true' || false);
  247.         PRM.size[2] = Number(Parameters["CancelBtn Size"]);
  248.         PRM.pos[2] = Parameters["CancelBtn Margin"].split(";");
  249.         PRM.spot[2] = Parameters["CancelBtn Orientation"].split(";");
  250.         PRM.flickpage = Boolean(Parameters["Flick PageUp-PageDown"] === 'true' || false);
  251.         PRM.holdaction = Boolean(Parameters["HoldCanvas ActionBtn"] === 'true' || false);
  252.         PRM.outcansel = Boolean(Parameters["OutCanvas CancelBtn"] === 'true' || false);
  253.         PRM.outaction = Boolean(Parameters["OutCanvas ActionBtn"] === 'true' || false);
  254.         PRM.analogmove = Boolean(Parameters["Analog Move"] === 'true' || false);
  255.         PRM.sensitivity = Number(Parameters["Analog Sensitivity"]);
  256.        
  257.         var btn_id=["DirPad","ok","escape"];
  258.         var current_zoom=1;       
  259.         var st_x = 0;
  260.         var st_y = 0;
  261.         var pad_range=PRM.size[0]*PRM.pad_scale;
  262.         var pad_size=pad_range*current_zoom/2;
  263.         var Btn_ready=false;
  264.         var Btn_hide=false;
  265.         var PressBtn=false;
  266.         var dirx=0;
  267.         var diry=0;
  268.         var touchx=0;
  269.         var touchy=0;
  270.         var autofire=false;
  271.         var hvzoom=[1, PRM.vZoom];
  272.         var ua = (function(u){
  273.           return {
  274.             Tablet:(u.indexOf("windows") != -1 && u.indexOf("touch") != -1) || u.indexOf("ipad") != -1 || (u.indexOf("android") != -1 && u.indexOf("mobile") == -1) || (u.indexOf("firefox") != -1 && u.indexOf("tablet") != -1) || u.indexOf("kindle") != -1 || u.indexOf("silk") != -1 || u.indexOf("playbook") != -1
  275.           };
  276.         })(window.navigator.userAgent.toLowerCase());

  277.         if(ua.Tablet){
  278.                 hvzoom=[PRM.tabZoom, PRM.tabvZoom];
  279.         }
  280.         if (!Utils.isMobileDevice() && !PRM.pcBtn) {PRM.visible[0]=PRM.visible[1]=PRM.visible[2]=false;}

  281.         //-----------------------------------------------------------------------------
  282.         // Locate_DirPad

  283.         function Locate_DirPad() {
  284.                 this.initialize.apply(this, arguments);
  285.         }


  286.         Locate_DirPad.prototype.initialize = function() {
  287.                 var img = new Image();
  288.                 var url = PRM.url[0];
  289.                 img.onerror = function() {Graphics.printError('DirPad Image was Not Found:',url);};
  290.                 img.src = url;
  291.                 img = null;
  292.                 this.Div = document.createElement("div");
  293.                 this.Div.id = 'Dirpad';
  294.                 this.Div.style.position = 'fixed';
  295.                 this.Div.style[PRM.spot[0][0].replace(/\s+/g, "")] = String(PRM.pos[0][0]-(pad_range-PRM.size[0])/2)+'px';
  296.                 this.Div.style[PRM.spot[0][1].replace(/\s+/g, "")] = String(PRM.pos[0][1]-(pad_range-PRM.size[0])/2)+'px';
  297.                 this.Div.style.width = pad_range+'px';
  298.                 this.Div.style.height = pad_range+'px';
  299.                 this.Div.style.opacity = PRM.opacity;
  300.                 this.Div.style.zIndex = '11';
  301.                 this.Div.style.userSelect="none";
  302.                 this.Div.style["-webkit-tap-highlight-color"]="rgba(0,0,0,0)";
  303.                 this.Div.style.background = 'url('+PRM.url[0]+') 50% 50% / '+String(Math.round(PRM.size[0]/pad_range*100))+'% no-repeat';
  304.                
  305.                 if(!Utils.isMobileDevice() && PRM.pcBtn){
  306.                         this.Div.addEventListener('mousedown', function(e) {
  307.                           if (!SceneManager.isSceneChanging()){dirope(e.layerX,e.layerY,true);PressBtn=true;}
  308.                         }, false);
  309.                         this.Div.addEventListener('mousemove', function(e) {
  310.                           if(PressBtn && !SceneManager.isSceneChanging()){dirope(e.layerX,e.layerY,false);}
  311.                         }, false);
  312.                         this.Div.addEventListener('mouseup', function() {
  313.                                 disope();PressBtn=false;
  314.                         }, false);
  315.                         this.Div.addEventListener('mouseout', function() {
  316.                             disope();PressBtn=false;
  317.                         }, false);
  318.                 }
  319.                 this.Div.addEventListener('touchstart', function(e) {
  320.                         PressBtn=true;
  321.                         if (!SceneManager.isSceneChanging()){dirope(e.touches[0].clientX-dirx, e.touches[0].clientY-diry,true)};
  322.                 }, false);
  323.                 this.Div.addEventListener('touchmove', function(e) {
  324.                         if (!SceneManager.isSceneChanging()){dirope(e.touches[0].clientX-dirx, e.touches[0].clientY-diry,false)};
  325.                         PressBtn=true;
  326.                 }, false);
  327.                 this.Div.addEventListener('touchend', function() {
  328.                         disope();PressBtn=false;
  329.                 }, false);
  330.                         document.body.appendChild(this.Div);
  331.         };
  332.        
  333.         function dirope(xx,yy,st) {
  334.                 touchx=(xx-pad_size)/pad_size;
  335.                 touchy=(yy-pad_size)/pad_size;
  336.                 if(st && Math.sqrt(touchx*touchx+touchy*touchy)>1){
  337.                         disope();
  338.                 }else{
  339.                         if(touchx>Math.abs(touchy)*PRM.pad_dia){Input._currentState['right']=true;Input._currentState['left']=false;}
  340.                         else if(touchx<-Math.abs(touchy)*PRM.pad_dia){Input._currentState['left']=true;Input._currentState['right']=false;}
  341.                         else{Input._currentState['left']=false;Input._currentState['right']=false;}
  342.                         if(touchy>Math.abs(touchx)*PRM.pad_dia){Input._currentState['down']=true;Input._currentState['up']=false;}
  343.                         else if(touchy<-Math.abs(touchx)*PRM.pad_dia){Input._currentState['up']=true;Input._currentState['down']=false;}
  344.                         else{Input._currentState['up']=false;Input._currentState['down']=false;}
  345.                 }
  346.         }
  347.         function disope() {
  348.                 touchx=0; touchy=0;
  349.                 Input._currentState['up']=false;
  350.                 Input._currentState['down']=false;
  351.                 Input._currentState['left']=false;
  352.                 Input._currentState['right']=false;
  353.         }
  354.        
  355.         //-----------------------------------------------------------------------------
  356.         // Locate_Button

  357.         function Locate_Button() {
  358.                 this.initialize.apply(this, arguments);
  359.         }
  360.         Locate_Button.prototype.initialize = function(type) {
  361.                 var img = new Image();
  362.                 var url = PRM.url[type];
  363.                 img.onerror = function() {Graphics.printError('Button Image was Not Found:',url);};
  364.                 img.src = url;
  365.                 img = null;
  366.                 this.Div = document.createElement("div");
  367.                 this.Div.id = btn_id[type]+'Btn';
  368.                 this.Div.style.position = 'fixed';
  369.                 this.Div.style[PRM.spot[type][0].replace(/\s+/g, "")] = PRM.pos[type][0]+'px';
  370.                 this.Div.style[PRM.spot[type][1].replace(/\s+/g, "")] = PRM.pos[type][1]+'px';
  371.                 this.Div.style.width = PRM.size[type]+'px';
  372.                 this.Div.style.height = PRM.size[type]+'px';
  373.                 this.Div.style.opacity = PRM.opacity;
  374.                 this.Div.style.zIndex = '11';
  375.                 this.Div.style.userSelect="none";
  376.                 this.Div.style.background = 'url('+PRM.url[type]+') 0 0 / cover no-repeat';
  377.                
  378.                 if(!Utils.isMobileDevice() && PRM.pcBtn){
  379.                         this.Div.addEventListener('mousedown', function() {
  380.                                 Input._currentState[btn_id[type]] = true;PressBtn=true;
  381.                         }, false);
  382.                         this.Div.addEventListener('mouseover', function() {
  383.                           if(TouchInput.isPressed()){Input._currentState[btn_id[type]] = true;PressBtn=true;return false;}
  384.                         }, false);
  385.                         this.Div.addEventListener('mouseup', function() {
  386.                           Input._currentState[btn_id[type]] = false;PressBtn=false;
  387.                         }, false);
  388.                         this.Div.addEventListener('mouseout', function() {
  389.                           Input._currentState[btn_id[type]] = false;PressBtn=false;
  390.                         }, false);
  391.                 }
  392.                
  393.                 this.Div.addEventListener('touchstart', function() {
  394.                         if (!SceneManager.isSceneChanging()){Input._currentState[btn_id[type]] = true;PressBtn=true;}
  395.                 }, false);
  396.                 this.Div.addEventListener('touchend', function() {
  397.                         Input._currentState[btn_id[type]] = false;PressBtn=false;
  398.                 }, false);
  399.                
  400.                 document.body.appendChild(this.Div);
  401.         };

  402.         //-----------------------------------------------------------------------------
  403.         // Replace function
  404.                        
  405.         var Scene_Base_start = Scene_Base.prototype.start;
  406.         Scene_Base.prototype.start = function() {
  407.                 Scene_Base_start.call(this);
  408.             if (Utils.isMobileDevice() || PRM.pcBtn) {
  409.                         if(!Btn_ready){
  410.                                 Btn_ready=true;
  411.                                 if(PRM.visible[0]){this.DirPad = new Locate_DirPad();}
  412.                                 if(PRM.visible[1]){this.okButton = new Locate_Button(1);}
  413.                                 if(PRM.visible[2]){this.canselButton = new Locate_Button(2);}
  414.                                 Graphics._updateRealScale();
  415.                                 document.documentElement.style["-webkit-user-select"]="none";
  416.                                 document.addEventListener("touchmove", function(evt) {evt.preventDefault();}, false);
  417.                         }
  418.                 }
  419.         };
  420.                
  421.         if(PRM.visible[0] || PRM.visible[1] || PRM.visible[2]){
  422.        
  423.                 var Game_Temp_setDestination = Game_Temp.prototype.setDestination;
  424.                 Game_Temp.prototype.setDestination = function(x, y) {
  425.                         Game_Temp_setDestination.apply(this, arguments);
  426.                         if(PressBtn){
  427.                                 this._destinationX = null;
  428.                                 this._destinationY = null;
  429.                         }
  430.                 };
  431.                
  432.                 var Graphics_updateRealScale = Graphics._updateRealScale;
  433.                 Graphics._updateRealScale = function() {
  434.                         Graphics_updateRealScale.call(this);
  435.                         if (this._stretchEnabled) {
  436.                                 if(document.getElementById("Dirpad")){
  437.                                 if(window.innerWidth<window.innerHeight){current_zoom=hvzoom[1];}else{current_zoom=hvzoom[0];}
  438.                                         pad_size=pad_range*current_zoom/2;
  439.                                         if(PRM.visible[0]){
  440.                                                 document.getElementById("Dirpad").style.zoom=current_zoom;
  441.                                                 dirx=document.getElementById("Dirpad").offsetLeft*current_zoom;
  442.                                                 diry=document.getElementById("Dirpad").offsetTop*current_zoom;
  443.                                         }
  444.                                         if(PRM.visible[1]){document.getElementById("okBtn").style.zoom=current_zoom;}
  445.                                         if(PRM.visible[2]){document.getElementById("escapeBtn").style.zoom=current_zoom;}
  446.                                 }
  447.                         }
  448.                 };
  449.         }
  450.        
  451.         //-----------------------------------------------------------------------------
  452.         // Option

  453.         if(PRM.hideBtn){
  454.                 Scene_Base.prototype.hideUserInterface = function() {
  455.                         if (Utils.isMobileDevice() || PRM.pcBtn) {Btn_hide=true;
  456.                                 if(PRM.visible[0]){document.getElementById("Dirpad").style.zIndex = '0';}
  457.                                 if(PRM.visible[1]){document.getElementById("okBtn").style.zIndex = '0';}
  458.                                 if(PRM.visible[2]){document.getElementById("escapeBtn").style.zIndex = '0';}
  459.                         }
  460.                 };
  461.                 Scene_Base.prototype.showUserInterface = function() {
  462.                         if (Utils.isMobileDevice() && !Btn_hide || PRM.pcBtn && !Btn_hide) {
  463.                                 if(PRM.visible[0]){document.getElementById("Dirpad").style.zIndex = '11';}
  464.                                 if(PRM.visible[1]){document.getElementById("okBtn").style.zIndex = '11';}
  465.                                 if(PRM.visible[2]){document.getElementById("escapeBtn").style.zIndex = '11';}
  466.                         }
  467.                 };
  468.        
  469.                 var Scene_Map_createMessageWindows = Scene_Map.prototype.createMessageWindow;
  470.                 var Scene_Map_processMapTouch = Scene_Map.prototype.processMapTouch;
  471.                 var Scene_Map_terminate = Scene_Map.prototype.terminate;
  472.                
  473.                 Scene_Map.prototype.createMessageWindow = function() {
  474.                         Scene_Map_createMessageWindows.call(this);
  475.                         var oldStartMessage = this._messageWindow.startMessage;
  476.                         var oldTerminateMessage = this._messageWindow.terminateMessage;
  477.                         var scene = this;
  478.                        
  479.                         this._messageWindow.startMessage = function() {       
  480.                                 oldStartMessage.apply(this, arguments);
  481.                                 if($gameMessage.positionType()==2){
  482.                                         //scene.hideUserInterface();
  483.                                 }
  484.                         };
  485.                         Window_Message.prototype.terminateMessage = function() {
  486.                                 oldTerminateMessage.apply(this, arguments);
  487.                                 Btn_hide=false;
  488.                                 setTimeout("Scene_Base.prototype.showUserInterface();", 200);
  489.                         };
  490.                 };
  491.                
  492.                 var Scene_Battle_createMessageWindow = Scene_Battle.prototype.createMessageWindow;
  493.                 Scene_Battle.prototype.createMessageWindow = function() {
  494.                         Scene_Battle_createMessageWindow.call(this);
  495.                         var oldStartMessage = this._messageWindow.startMessage;
  496.                         var oldTerminateMessage = this._messageWindow.terminateMessage;
  497.                         var scene = this;
  498.                         this._messageWindow.startMessage = function() {
  499.                                 oldStartMessage.apply(this, arguments);
  500.                                 if($gameMessage.positionType()==2){
  501.                                         //scene.hideUserInterface();
  502.                                 }
  503.                         };
  504.                         Window_Message.prototype.terminateMessage = function() {
  505.                                 oldTerminateMessage.apply(this, arguments);
  506.                                 Btn_hide=false;
  507.                                 setTimeout("Scene_Base.prototype.showUserInterface();", 200);
  508.                         };
  509.                 };
  510.         }

  511.         if(Utils.isMobileDevice() || PRM.pcExt){
  512.                 if(PRM.holdaction){
  513.                         var TouchInput_update = TouchInput.update;
  514.                         TouchInput.update = function() {
  515.                                 TouchInput_update.call(this);
  516.                                 if (!PressBtn && TouchInput.isLongPressed()) {
  517.                                         Input._currentState['ok']=true;autofire=true;
  518.                                 }
  519.                                 if(!TouchInput.isPressed() && autofire){
  520.                                         Input._currentState['ok']=false;autofire=false;
  521.                                 }
  522.                         };
  523.                 }
  524.                
  525.                 if(PRM.flickpage || PRM.outcansel || PRM.outaction){
  526.                         TouchInput._endRequest= function(type) {
  527.                                 Input._currentState[type]=false;
  528.                         }
  529.                         if(Utils.isMobileDevice()){
  530.                                 var TouchInput_onTouchStart = TouchInput._onTouchStart;
  531.                                 TouchInput._onTouchStart = function(event) {
  532.                                     TouchInput_onTouchStart.apply(this, arguments);
  533.                                         var touch = event.changedTouches[0];
  534.                                         if(!PressBtn){
  535.                                                 st_x = Graphics.pageToCanvasX(touch.pageX);
  536.                                                 st_y = Graphics.pageToCanvasY(touch.pageY);
  537.                                                 if(st_x<0 || st_y<0 || st_x>Graphics.boxWidth || st_y>Graphics.boxHeight){
  538.                                                         if(PRM.outcansel){Input._currentState['escape']=true;setTimeout("TouchInput._endRequest('escape');", 100);}
  539.                                                         if(PRM.outaction){Input._currentState['ok']=true;setTimeout("TouchInput._endRequest('ok');", 100);}
  540.                                                 }
  541.                                         }
  542.                                 };
  543.                         }else{
  544.                                 var TouchInput_onLeftButtonDown = TouchInput._onLeftButtonDown;
  545.                                 TouchInput._onLeftButtonDown = function(event) {
  546.                                         TouchInput_onLeftButtonDown.apply(this, arguments);
  547.                                         if(!PressBtn){
  548.                                                 st_x = Graphics.pageToCanvasX(event.pageX);
  549.                                                 st_y = Graphics.pageToCanvasY(event.pageY);
  550.                                                 if(st_x<0 || st_y<0 || st_x>Graphics.boxWidth || st_y>Graphics.boxHeight){
  551.                                                         if(PRM.outcansel){Input._currentState['escape']=true;setTimeout("TouchInput._endRequest('escape');", 100);}
  552.                                                         if(PRM.outaction){Input._currentState['ok']=true;setTimeout("TouchInput._endRequest('ok');", 100);}
  553.                                                 }
  554.                                         }
  555.                                 };
  556.                         }
  557.                 }
  558.                        
  559.                 if(PRM.flickpage){
  560.                         var TouchInput_onMove = TouchInput._onMove;
  561.                         TouchInput._onMove = function(x, y) {
  562.                                 TouchInput_onMove.apply(this, arguments);
  563.                                 if(!PressBtn){
  564.                                         if((st_x-x)<-50 && Math.abs(st_y-y)<100){st_y=9999;Input._currentState['pageup']=true;setTimeout("TouchInput._endRequest('pageup');", 100);}
  565.                                         if((st_x-x)>50 && Math.abs(st_y-y)<100){st_y=9999;Input._currentState['pagedown']=true;setTimeout("TouchInput._endRequest('pagedown');", 100);}
  566.                                 }
  567.                         }
  568.                 }
  569.         }
  570.        
  571.         //AnalogMove.js
  572.         if(PRM.analogmove && Utils.isMobileDevice() || PRM.analogmove && PRM.pcBtn){
  573.                 Input.leftStick = function() {
  574.                         var threshold = 0.1;
  575.                         var x = touchx;
  576.                         var y = touchy;
  577.                         var tilt = Math.min(1,Math.sqrt(touchx*touchx+touchy*touchy)*PRM.sensitivity);
  578.                         var direction = 0.0;
  579.                         if (x === 0.0) {
  580.                                 direction = (-y > 0 ? Math.PI * 0.0 : Math.PI * 1.0);
  581.                         } else if (y === 0.0) {
  582.                                 direction = (-x > 0 ? Math.PI * 0.5 : Math.PI * 1.5);
  583.                         } else {
  584.                                 direction = Math.atan2(-x, -y);
  585.                         }
  586.                         return {tilt: tilt, direction: direction};
  587.                 };
  588.         }
  589. })(UCHU_MobileOperation);
复制代码
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部