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

Project1

 找回密码
 注册会员
搜索
查看: 3115|回复: 6
打印 上一主题 下一主题

[原创发布] 右上角添加ESC,取消按键

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

跳转到指定楼层
1
发表于 2019-6-2 15:28:34 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 yang1zhi 于 2019-6-2 15:51 编辑

写的不好,有什么BUG我也不知道。
应该没有BUG

把图放在system文件夹里
把脚本做成插件使用

窗口界面时的取消功能是采用了Window_Selectable的取消函数CancelCancel

地图界面时是使用的打开菜单

ESC会出现在所有Scene_Map的界面,Scene_MenuBase的界面




脚本


截图

评分

参与人数 2+2 收起 理由
if216 + 1 无情拷走
白嫩白嫩的 + 1 大佬666

查看全部评分

Lv3.寻梦者

梦石
0
星屑
1390
在线时间
231 小时
注册时间
2017-10-24
帖子
209
2
发表于 2019-9-25 22:55:12 | 只看该作者
能设置 自己修改图片的位置吗

点评

new Window_esc这个后面括号里,自己改  发表于 2019-9-25 23:26
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
2577
在线时间
362 小时
注册时间
2015-8-15
帖子
80
3
发表于 2020-6-8 08:53:13 | 只看该作者
希望楼主更新一个版本,所有功能可以通过按钮的形式操作
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7531
在线时间
1227 小时
注册时间
2008-12-14
帖子
555
4
发表于 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 精品文章

查看全部评分

需要购买本人MV插件必须先加wx好友。加不上wx就是本人忙,没时间卖。原则上太久以前的插件也不想卖,因为我也忘了,维护上会不给力。wx名:alskyif    本人插件地址:
   LCK_SRPG梦幻模拟战、火焰纹章类系统
   究极立绘ADV系统

   究极换装统合系统
   究极! 回想与CG系统
   消息文字的距离调整  
   自动返回上一张地图
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-5-15 15:19

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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