查看: 5131|回复: 4

[已经解决] 不好意思 想要在游戏中出现输入框的效果 求助大神

[复制链接]
梦石
0
星屑
4891
在线时间
889 小时
注册时间
2014-12-3
回帖
44
发表于 2016-5-14 02:47:26 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 a66294836 于 2016-5-14 02:48 编辑

因为想要做出输入帐号的效果 所以想要输入框

但是在经查询后都没有类似的脚本 目前66RPG只有发现一篇文

不过小的学艺不精 看不懂 希望有大大能够用腳本的方式或插件

可以指导下 另外希望有清除文字的效果

谢谢

这是那篇的文章
https://rpg.blue/thread-384621-1-1.html
梦石
0
星屑
22879
在线时间
8598 小时
注册时间
2011-12-31
回帖
3270
发表于 2016-5-14 11:25:23 | 显示全部楼层
本帖最后由 tseyik 于 2016-5-14 11:38 编辑

InputFrom.js
使用方法
* @help InputForm x=350;y=200;v=11;max=5;
* 這例子:表示在位置x350,y200、輸入結果存入変数11中。
* 最大文字数為5(max省略時字数無制限)
*
* 時間切れなどを作りたい時は、if_s=3;を付けると
* ”スイッチ3がONになった場合”に強制終了できます
* 並列イベントの中で、スイッチ3をONにするイベントを作りましょう
*
* css文件夾中可用111_InputForm.css。
* 111_InputForm.css可設定文字大小,字色,背景色,背景透明……及其他
*
* 入力が終わるまで次のイベントコマンドは読み込みません
InputFrom.js
  1. //=============================================================================
  2. // InputFrom.js
  3. //=============================================================================

  4. /*:
  5. * @plugindesc フォーム作って文字入力
  6. * @author 111
  7. *
  8. *
  9. * @help InputForm x=350;y=200;v=11;max=5;
  10. * みたいな感じで。この例だとx350,y200の位置に表示、結果を11番の変数に保存。
  11. * 最大文字数は5(maxは省略すれば無制限にもできる)
  12. *
  13. * 時間切れなどを作りたい時は、if_s=3;を付けると
  14. * ”スイッチ3がONになった場合”に強制終了できます
  15. * 並列イベントの中で、スイッチ3をONにするイベントを作りましょう
  16. *
  17. * cssフォルダを作ってそこに111_InputForm.cssを入れること。
  18. * 111_InputForm.cssをいじって文字の大きさとかも変えられる
  19. *
  20. * 入力が終わるまで次のイベントコマンドは読み込みません
  21. */
  22. (function() {
  23.     // css追加
  24.     (function(){
  25.         var css = document.createElement('link');
  26.         css.rel = "stylesheet";
  27.         css.type = 'text/css';
  28.         css.href = './css/111_InputForm.css';
  29.         var b_top = document.getElementsByTagName('head')[0];
  30.         b_top.appendChild(css);
  31.     })();
  32.     // キー入力不可にする為に
  33.     Input.form_mode = false;
  34.     var _Input_onKeyDown = Input._onKeyDown;
  35.     Input._onKeyDown = function(event) {
  36.         if(Input.form_mode)return;
  37.         _Input_onKeyDown.call(this , event)
  38.     };
  39.     var _Input_onKeyUp = Input._onKeyUp;
  40.     Input._onKeyUp = function(event) {
  41.         if(Input.form_mode)return;
  42.         _Input_onKeyUp.call(this , event)
  43.     };
  44.     // 入力終わるまで次のイベントコマンド読み込まない
  45.     var _Game_Interpreter_updateWaitMode =
  46.             Game_Interpreter.prototype.updateWaitMode;   
  47.     Game_Interpreter.prototype.updateWaitMode = function(){
  48.         if(this._waitMode == 'input_form')return true;
  49.         return _Game_Interpreter_updateWaitMode.call(this);
  50.     }

  51.     HTMLElement.prototype.postionAdjust = function(screen_postion , target_postion){
  52.         this.style.left = ((screen_postion[0] + target_postion[0]) / window.innerWidth * 100) + "%";
  53.         this.style.top  = ((screen_postion[1] + target_postion[1]) / window.innerHeight * 100) + "%";
  54.     };
  55.     // 引数のx=350;y=200;みたいなのを可能にする
  56.     var argHash = function(text , arg_names){
  57.         var _args = new Array(arg_names.length);
  58.         var ary = text.split(";");
  59.         ary.forEach(function(str){
  60.             var s_ary = str.split("=");
  61.             var prop = s_ary[0].toLowerCase();
  62.             var value = s_ary[1];
  63.             _args[arg_names.indexOf(prop)] = value;
  64.         });
  65.         return _args;
  66.     }   
  67.     //=============================================================================
  68.     // Game_Interpreter - register plugin commands
  69.     //=============================================================================
  70.     var _Game_Interpreter_pluginCommand =
  71.             Game_Interpreter.prototype.pluginCommand;
  72.     Game_Interpreter.prototype.pluginCommand = function(command, args) {
  73.         _Game_Interpreter_pluginCommand.call(this, command, args);
  74.         if (command === 'InputForm'){
  75.             var _ary = argHash(args[0] , ["x" , "y" , "v" , "max" , "if_s"]);
  76.             var target_x = +_ary[0];
  77.             var target_y = +_ary[1];
  78.             var variables_id = +_ary[2];
  79.             var max_count = _ary[3] || null;
  80.             var if_switch_id = Number(_ary[4]) || null;
  81.             var result_switch_id = Number(_ary[5]) || null;

  82.             var interpreter = this;
  83.             var gui = {
  84.                 input : null ,
  85.                 submit : null ,
  86.                 is_pc : true ,
  87.                 init : function(){
  88.                     this.is_pc = Utils.isNwjs();
  89.                     this.create();
  90.                     this.input.focus();
  91.                     this.screenAdjust();
  92.                 } ,
  93.                 create : function(){
  94.                     // 入力フォーム
  95.                     this.input = document.createElement('input');
  96.                     this.input.setAttribute('id', '_111_input');
  97.                     if(max_count)this.input.setAttribute('maxlength', max_count);
  98.                     document.body.appendChild(this.input);
  99.                     // 送信ボタン
  100.                     this.submit = document.createElement('input');
  101.                     this.submit.setAttribute('type', 'submit');
  102.                     this.submit.setAttribute('id', '_111_submit');
  103.                     this.submit.setAttribute('value', '決定');
  104.                     document.body.appendChild(this.submit);
  105.                 } ,
  106.                 success : function(){
  107.                     $gameVariables.setValue(variables_id , this.input.value);
  108.                     this.end();
  109.                 } ,
  110.                 cancel : function(){
  111.                     $gameVariables.setValue(variables_id , this.input.value);
  112.                     this.end();
  113.                 } ,
  114.                 start : function(){
  115.                     interpreter.setWaitMode('input_form');
  116.                     Input.clear();
  117.                     Input.form_mode = true;
  118.                     // SceneManager._scene.stop();
  119.                 } ,
  120.                 end : function(){
  121.                     this.input.remove(); // document.body.removeChild(this.input);
  122.                     this.submit.remove();
  123.                     window.removeEventListener("resize", this.screenAdjust, false);
  124.                     interpreter.setWaitMode('');
  125.                     Input.form_mode = false;
  126.                     // SceneManager._scene.start();
  127.                 } ,
  128.                 screenAdjust : function(){ // canvasの左上を基準にした位置に合わせる
  129.                     var screen_x , screen_y;
  130.                     var _canvas = document.querySelector('#UpperCanvas');
  131.                     var rect = _canvas.getBoundingClientRect();
  132.                     if(! this.is_pc){ // web用座標
  133.                         screen_x = rect.x;
  134.                         screen_y = rect.y;
  135.                     }else{ // exe用(左上0,0からでOK)
  136.                         screen_x = 0;
  137.                         screen_y = 0;
  138.                     }
  139.                     this.input.postionAdjust([screen_x,screen_y] , [target_x,target_y + 40]);
  140.                     this.submit.postionAdjust([screen_x,screen_y] , [target_x,target_y]);
  141.                 }
  142.             }
  143.             //
  144.             gui.init();
  145.             // 送信するイベントgui.input.onkeydown = function(e){
  146.             gui.input.addEventListener("keydown" ,function(e){
  147.                 if(e.keyCode === 13){ // 決定キーで送信
  148.                     Input.clear();
  149.                     gui.success();
  150.                     // 親へのイベント伝播を止める(documentのkeydownが反応しないように)
  151.                     e.stopPropagation();
  152.                 }
  153.             });
  154.             gui.submit.addEventListener("click" ,function(){ // 送信ボタンクリック
  155.                 gui.success();
  156.                 return false;
  157.             });
  158.             // キャンセルするイベント
  159.             var _event = setInterval(function(){
  160.                 if($gameSwitches.value(if_switch_id)){
  161.                     clearInterval(_event);
  162.                     gui.cancel();
  163.                 }
  164.             }, 1);

  165.             // webではウィンドー大きさ変わる度に%求め直すイベントもいる
  166.             if(! gui.is_pc){
  167.                 window.addEventListener("resize", gui.screenAdjust.bind(gui), false);
  168.             }
  169.             //
  170.             gui.start();
  171.         }
  172.     };
  173. })();
复制代码



111_InputForm.css
  1. #_111_input{
  2.     /*位置指定*/
  3.     position: absolute;
  4.     /*重なり優先度*/
  5.     z-index:999;
  6.     /*フォントサイズ*/
  7.     font-size: 24px;
  8.     /*幅*/
  9.     width : 15em;
  10.     /*高さ*/
  11.     height : 1.5em;

  12.     /*ここからフォント定義追加*/
  13.     font-weight:bold;
  14.     color: #f8f8f8;
  15.     text-shadow: black 1px 1px 0px, black -1px 1px 0px,
  16.                  black 1px -1px 0px, black -1px -1px 0px;
  17.     font-family: GameFont;

  18.     /*ここからボックス定義追加*/
  19.   border:solid 3px #f8f8f8;
  20.   border-radius:5px;
  21.   background: rgba(0,0,0, 0.5);
复制代码


css改造方法
http://qiita.com/fftfantt/items/2a8348b64d66f5816350
Image001.png
Image002.png
Image003.png
Image004.png
Image005.png

点评

666666  发表于 2020-4-11 22:35
抱歉 求助一下大神 插件指令我用了InputForm x=350;y=200;v=11;max=5; 却显示在视窗外面 没办法调座标 不知道是什么问题=口=  发表于 2016-5-15 16:33
感谢大神 赞叹大神  发表于 2016-5-15 14:06

评分

参与人数 2星屑 +30 梦石 +1 收起 理由
余烬之中 + 1 认可答案
a66294836 + 30 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部