查看: 5157|回复: 3

[原创发布] 某些窗口添加鼠标滚轮,触摸移动改变数值

[复制链接]
梦石
0
星屑
1232
在线时间
1017 小时
注册时间
2011-4-30
回帖
1464
发表于 2015-11-25 20:05:52 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 汪汪 于 2015-11-28 09:57 编辑

有的数字操作需要按很多下的,  实在是太累人了.
所以添加了鼠标滚轮和触摸移动..
如果已经有了的话就忽视吧...

鼠标滚轮,触摸移动,改变数字


  1. //=============================================================================
  2. // Window_wheel.js
  3. //=============================================================================
  4. /*:
  5. * @plugindesc 添加通过  鼠标滚轮或触摸移动  改变数字的方法
  6. * @author wangwang
  7. *
  8. * @param NumberInput_z
  9. * @desc 数字输入窗口,默认1个数字所需的移动距离
  10. * @default 50
  11. *
  12. * @param Options_z
  13. * @desc 选项窗口,默认1次操作所需的移动距离
  14. * @default 50
  15. *
  16. * @param ShopNumber_z
  17. * @desc 商店窗口默认1个数字所需的移动距离
  18. * @default 50
  19. *
  20. * @help
  21. * 商店数字 ,数字输入 ,选项窗口
  22. *
  23. */




  24. (function() {

  25. var Window_wheel_ShopNumber_z = parseInt(PluginManager.parameters("Window_wheel")["ShopNumber_z"], 10);
  26. var Window_wheel_Options_z = parseInt(PluginManager.parameters("Window_wheel")["Options_z"], 10);
  27. var Window_wheel_NumberInput_z= parseInt(PluginManager.parameters("Window_wheel")["NumberInput_z"], 10);




  28. //滚轮相关
  29. //商店
  30. Window_ShopNumber.prototype.scrollUp = function() {
  31.     this.changeNumber(1);
  32. };

  33. Window_ShopNumber.prototype.scrollDown = function() {
  34.     this.changeNumber(-1);
  35. };

  36. //数字输入
  37. Window_NumberInput.prototype.scrollUp = function() {
  38.     this.changeDigit(true);
  39. };
  40. Window_NumberInput.prototype.scrollDown = function() {
  41.     this.changeDigit(false);
  42. };


  43. //滚轮
  44. Window_Options.prototype.scrollUp = function() {
  45.         var index = this.index();
  46.     var symbol = this.commandSymbol(index);
  47.     var value = this.getConfigValue(symbol);
  48.     if (this.isVolumeSymbol(symbol)) {
  49.         value += this.volumeOffset();
  50.         value = value.clamp(0, 100);
  51.         this.changeValue(symbol, value);
  52.     } else {
  53.         this.changeValue(symbol, true);
  54.     }
  55. };

  56. Window_Options.prototype.scrollDown = function() {
  57.     var index = this.index();
  58.     var symbol = this.commandSymbol(index);
  59.     var value = this.getConfigValue(symbol);
  60.     if (this.isVolumeSymbol(symbol)) {
  61.         value -= this.volumeOffset();
  62.         value = value.clamp(0, 100);
  63.         this.changeValue(symbol, value);
  64.     } else {
  65.         this.changeValue(symbol, false);
  66.     }
  67. };




  68. //触摸相关

  69. //商店
  70. Window_ShopNumber.prototype.processTouch = function() {
  71.     if (this.isOpenAndActive()) {
  72.         if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  73.             this._touching = true;
  74.             this.onTouch(true);
  75.             this.Touchmovest()
  76.         } else if (TouchInput.isTriggered() ){
  77.                     this.Touchmovest()
  78.         } else if (TouchInput.isPressed() && TouchInput.isMoved()){
  79.                 this.Touchmove()
  80.         } else if (TouchInput.isCancelled()) {
  81.             if (this.isCancelEnabled()) {
  82.                 this.processCancel();
  83.             }
  84.         }
  85.         if (this._touching) {
  86.             if (TouchInput.isPressed()) {
  87.                 this.onTouch(false);
  88.             } else {
  89.                 this._touching = false;
  90.             }
  91.         }
  92.     } else {
  93.         this._touching = false;
  94.     }
  95. };



  96. Window_ShopNumber.prototype.Touchmovest = function() {
  97.         this._touch_x = TouchInput.x  
  98.     this._touch_y = TouchInput.y
  99.     this._touch_z = 0
  100. }


  101. Window_ShopNumber.prototype.Touchmove = function () {
  102.     var x = TouchInput.x
  103.         x = x - this._touch_x  
  104.     var y = TouchInput.y
  105.         y = this._touch_y - y

  106.     this._touch_z = this._touch_z || 0

  107.    
  108.     var z = Math.floor((x+y)/ Window_wheel_ShopNumber_z)
  109.     if (!isNaN(z)){
  110.             if (this._touch_z !== z){
  111.                         this.changeNumber(z-this._touch_z)
  112.                         this._touch_z = z
  113.             }
  114.         }
  115. }


  116. //选项
  117. Window_Options.prototype.processTouch = function() {
  118.     if (this.isOpenAndActive()) {
  119.         if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  120.             this._touching = true;
  121.             this.onTouch(true);
  122.         } else if (TouchInput.isTriggered()&& !this.isTouchedInsideFrame()  ){
  123.                     this.Touchmovest()
  124.         } else if (TouchInput.isPressed()&& !this.isTouchedInsideFrame() && TouchInput.isMoved()){
  125.                 this.Touchmove()
  126.         } else if (TouchInput.isCancelled()) {
  127.             if (this.isCancelEnabled()) {
  128.                 this.processCancel();
  129.             }
  130.         }
  131.         if (this._touching) {
  132.             if (TouchInput.isPressed()) {
  133.                 this.onTouch(false);
  134.             } else {
  135.                 this._touching = false;
  136.             }
  137.         }
  138.     } else {
  139.         this._touching = false;
  140.     }
  141. };




  142. Window_Options.prototype.Touchmovest = function() {
  143.         this._touch_x = TouchInput.x  
  144.     this._touch_y = TouchInput.y
  145.     this._touch_z = 0
  146. }


  147. Window_Options.prototype.Touchmove = function () {
  148.        
  149.     var x = TouchInput.x
  150.         x = x - this._touch_x  
  151.         
  152.     var y = TouchInput.y
  153.         y = this._touch_y - y

  154.     this._touch_z = this._touch_z || 0
  155.    
  156.     var z = Math.floor((x+y)/ Window_wheel_Options_z)
  157.     if (!isNaN(z)){
  158.             if (this._touch_z !== z){
  159.                 if (this._touch_z < z){
  160.                         for (var i = this._touch_z ;i<z ;i++){
  161.                                          this.scrollUp()
  162.                         }
  163.                         this._touch_z = z
  164.                 }else if(this._touch_z > z){
  165.                         for (var i = this._touch_z ;i>z ;i--){
  166.                                          this.scrollDown()
  167.                         }
  168.                         this._touch_z = z
  169.                 }  
  170.             }
  171.     }
  172. }


  173. //数字输入
  174. Window_NumberInput.prototype.processTouch = function() {
  175.     if (this.isOpenAndActive()) {
  176.         if (TouchInput.isTriggered() && this.isTouchedInsideFrame()) {
  177.             this._touching = true;
  178.             this.onTouch(true);
  179.         } else if (TouchInput.isTriggered()&& !this.isTouchedInsideFrame() ){
  180.                     this.Touchmovest()
  181.         } else if (TouchInput.isPressed()&& !this.isTouchedInsideFrame() && TouchInput.isMoved()){
  182.                 this.Touchmove()
  183.         } else if (TouchInput.isCancelled()) {
  184.             if (this.isCancelEnabled()) {
  185.                 this.processCancel();
  186.             }
  187.         }
  188.         if (this._touching) {
  189.             if (TouchInput.isPressed()) {
  190.                 this.onTouch(false);
  191.             } else {
  192.                 this._touching = false;
  193.             }
  194.         }
  195.     } else {
  196.         this._touching = false;
  197.     }
  198. };




  199. Window_NumberInput.prototype.Touchmovest = function() {
  200.         this._touch_x = TouchInput.x  
  201.     this._touch_y = TouchInput.y
  202.     this._touch_z = 0
  203. }


  204. Window_NumberInput.prototype.Touchmove = function () {
  205.     var x = TouchInput.x
  206.         x = x - this._touch_x  
  207.         
  208.     var y = TouchInput.y
  209.         y = this._touch_y - y

  210.     this._touch_z = this._touch_z || 0
  211.     var z = Math.floor((x+y)/ Window_wheel_NumberInput_z )
  212.     if (!isNaN(z)){
  213.             if (this._touch_z !== z){
  214.                 if (this._touch_z < z){
  215.                         for (var i = this._touch_z ;i<z ;i++){
  216.                                          this.changeDigit(true)
  217.                         }
  218.                         this._touch_z = z
  219.                 }else if(this._touch_z > z){
  220.                         for (var i = this._touch_z ;i>z ;i--){
  221.                                          this.changeDigit(false)
  222.                         }
  223.                         this._touch_z = z
  224.                 }  
  225.             }
  226.     }
  227. }
































  228. })();
复制代码



评分

参与人数 2梦石 +1 赞 +1 收起 理由
橘子吖 + 1 我很赞同
余烬之中 + 1 原创发布

查看全部评分

梦石
0
星屑
50
在线时间
289 小时
注册时间
2014-12-12
回帖
138
发表于 2015-11-26 18:49:46 | 显示全部楼层
作用不大,毕竟如果制作过的人都懂,...

点评

没有面给  发表于 2020-6-16 10:01
PPT 制作
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部