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

Project1

 找回密码
 注册会员
搜索

右上角添加ESC,取消按键

查看数: 3364 | 评论数: 3 | 收藏 5
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2019-6-2 15:28

正文摘要:

本帖最后由 yang1zhi 于 2019-6-2 15:51 编辑 写的不好,有什么BUG我也不知道。 应该没有BUG 把图放在system文件夹里 把脚本做成插件使用 窗口界面时的取消功能是采用了Window_Selectable的取消函数CancelCance ...

回复

if216 发表于 2020-6-12 01:31:51
楼主,我加了些设置,希望对你也有用。加了图片名称、宽、高、右边距、上边距的设置。这样更灵活。发布在这层楼。如果不喜欢我的修改或发布,请联系我删除这层。
  1. //取消键---------------------------------------------------------
  2. var Imported = Imported || {};
  3. Imported.yang1zhi_esc = true;


  4. /*:
  5. * @plugindesc  取消键!
  6. * @author 杨志(yang1zhi)
  7. *
  8. * @param ---Configuration---
  9. *
  10. * @param Pic Name
  11. * @desc pic name
  12. * @default ESC
  13. *
  14. * @param Pic Width
  15. * @desc width
  16. * @default 32
  17. *
  18. * @param Pic Height
  19. * @desc height
  20. * @default 32
  21. *
  22. * @param Right Edge
  23. * @desc right_edge
  24. * @default 10
  25. *
  26. * @param Up Edge
  27. * @desc up_edge
  28. * @default 10
  29. *
  30. * @param
  31. * @help
  32. * ------------------------------------------------------------------------------
  33. *                                 取消键
  34. * ------------------------------------------------------------------------------
  35. */

  36. //Initialize global variables


  37. (function () {

  38. var params = PluginManager.parameters("yang1zhi_esc");
  39. var name = String(params["Pic Name"]);
  40. var esc_width = Number(params["Pic Width"]);
  41. var esc_height = Number(params["Pic Height"]);
  42. var right_edge = Number(params["Right Edge"]);
  43. var up_edge = Number(params["Up Edge"]);

  44. Scene_Map.prototype.isMapTouchOk = function() {
  45.         if (this.is_NOmove_window()) {return false}
  46.     return this.isActive() && $gamePlayer.canMove();
  47. };

  48. //点击后不会移动的窗口
  49. Scene_Map.prototype.is_NOmove_window = function() {
  50.         //ESC窗口
  51.         if (SceneManager._scene._escWindow.containsPoint({x: TouchInput.x, y: TouchInput.y})) {return true}
  52.         return false
  53. }


  54. ESC_SELECTABLE_UPDATE = Window_Selectable.prototype.update
  55. Window_Selectable.prototype.update = function() {
  56.     ESC_SELECTABLE_UPDATE.call(this);
  57.         this.CancelCancel();  //取消键
  58. };

  59. Window_Selectable.prototype.CancelCancel = function() {
  60.         //不活动的窗口跳过
  61.         if (!SceneManager._scene._escWindow) {return}
  62.         //不活动的窗口跳过
  63.         if (!this.isOpenAndActive()) {return}
  64.         //当按下鼠标左键
  65.         if (this.isCancelEnabled() && TouchInput.isTriggered('ok')) {
  66.         //当鼠标X在取消键范围内
  67.         if (SceneManager._scene._escWindow.containsPoint({x: TouchInput.x, y: TouchInput.y})) {
  68.                 this.processCancel();
  69.         }
  70.         }

  71. };


  72. ESC_DISPLAYOBJECTS = Scene_Map.prototype.createDisplayObjects
  73. Scene_Map.prototype.createDisplayObjects = function() {
  74.     ESC_DISPLAYOBJECTS.call(this);
  75.         this.createescWindow();  //ESC键
  76. };

  77. ESC_MENUBASE_SREATE = Scene_MenuBase.prototype.create
  78. Scene_MenuBase.prototype.create = function() {
  79.     ESC_MENUBASE_SREATE.call(this);
  80.         this.createescWindow();  //ESC键

  81. };


  82. Scene_Base.prototype.createescWindow = function() {
  83.     this._escWindow = new Window_esc(Graphics.width- esc_width - right_edge,up_edge,esc_width,esc_height,this.constructor.name);
  84.     this.addChild(this._escWindow);
  85. };

  86. Scene_Base.prototype.onESCOk = function() {
  87.         //Scene_Map.isActive()
  88.         this._escWindow.activate();
  89.         if (this.constructor.name == 'Scene_Map') {SceneManager.push(Scene_Menu);}
  90. };





  91. //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  92. //显示特效图片----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  93. function Window_esc() {
  94.     this.initialize.apply(this, arguments);
  95. }

  96. Window_esc.prototype = Object.create(Sprite.prototype);
  97. Window_esc.prototype.constructor = Window_esc;

  98. Window_esc.prototype.initialize = function(x, y,w,h,name) {
  99.     Sprite.prototype.initialize.call(this);
  100.         this._sc_name = name
  101.         var ww = w || 32
  102.         var hh = h || 32
  103.         this.move(x,y)
  104.     this.contents = new Sprite(new Bitmap(ww, hh));
  105.     this.addChild(this.contents);
  106.         this.bitmap = ImageManager.loadSystem('ESC');
  107. };



  108. Window_esc.prototype.update = function() {
  109.    Sprite.prototype.update.call(this);
  110.    //不在地图上跳过
  111.    if (this._sc_name != 'Scene_Map') {return}
  112.         //当按下鼠标左键
  113.         if (TouchInput.isTriggered('ok')) {
  114.         //当鼠标X在取消键范围内
  115.         if (this.containsPoint({x: TouchInput.x, y: TouchInput.y})) {
  116.                 //演奏SE
  117.                 SoundManager.playSystemSound(1);
  118.                 SceneManager.push(Scene_Menu);
  119.         }
  120.         }
  121. };
  122. Window_esc.prototype.show = function() {
  123.     this.visible = this.contents.visible = true;
  124. };
  125. Window_esc.prototype.hide = function() {
  126.     this.visible = this.contents.visible = false;
  127. };
  128. Window_esc.prototype.setAnchor = function (ax, ay) {
  129.     this.anchor.x = this.contents.anchor = ax;
  130.     this.anchor.y = this.contents.anchor = ay;
  131. };
  132. Window_esc.prototype.clear = function() {
  133.     this.contents.bitmap.clear();
  134. };
  135. Window_esc.prototype.drawIcon = function(iconIndex, x, y) {
  136.     var bitmap = ImageManager.loadSystem('IconSet');
  137.     var sx = iconIndex % 16 * esc_width;
  138.     var sy = Math.floor(iconIndex / 16) * esc_width;
  139.     this.contents.bitmap.blt(bitmap, sx, sy, esc_width, esc_height, x, y);
  140. };


  141. })();
复制代码

点评

喜欢,喜欢的很!!不要删 哈哈哈  发表于 2020-6-12 01:41

评分

参与人数 3+3 收起 理由
yang1zhi + 1 维护世界和平就靠你了
hanyilun + 1 精品文章
白嫩白嫩的 + 1 精品文章

查看全部评分

梦幻のLoli塔 发表于 2020-6-8 08:53:13
希望楼主更新一个版本,所有功能可以通过按钮的形式操作
q119498229 发表于 2019-9-25 22:55:12
能设置 自己修改图片的位置吗

点评

new Window_esc这个后面括号里,自己改  发表于 2019-9-25 23:26
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2025-7-17 21:59

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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