Project1
标题:
右上角添加ESC,取消按键
[打印本页]
作者:
yang1zhi
时间:
2019-6-2 15:28
标题:
右上角添加ESC,取消按键
本帖最后由 yang1zhi 于 2019-6-2 15:51 编辑
写的不好,有什么BUG我也不知道。
应该没有BUG
把图放在system文件夹里
把脚本做成插件使用
窗口界面时的取消功能是采用了Window_Selectable的取消函数CancelCancel
地图界面时是使用的打开菜单
ESC会出现在所有Scene_Map的界面,Scene_MenuBase的界面
ESC.png
(5.3 KB, 下载次数: 51)
下载附件
保存到相册
2019-6-2 15:28 上传
脚本
截图
作者:
q119498229
时间:
2019-9-25 22:55
能设置 自己修改图片的位置吗
作者:
梦幻のLoli塔
时间:
2020-6-8 08:53
希望楼主更新一个版本,所有功能可以通过按钮的形式操作
作者:
if216
时间:
2020-6-12 01:31
楼主,我加了些设置,希望对你也有用。加了图片名称、宽、高、右边距、上边距的设置。这样更灵活。发布在这层楼。如果不喜欢我的修改或发布,请联系我删除这层。
//取消键---------------------------------------------------------
var Imported = Imported || {};
Imported.yang1zhi_esc = true;
/*:
* @plugindesc 取消键!
* @author 杨志(yang1zhi)
*
* @param ---Configuration---
*
* @param Pic Name
* @desc pic name
* @default ESC
*
* @param Pic Width
* @desc width
* @default 32
*
* @param Pic Height
* @desc height
* @default 32
*
* @param Right Edge
* @desc right_edge
* @default 10
*
* @param Up Edge
* @desc up_edge
* @default 10
*
* @param
* @help
* ------------------------------------------------------------------------------
* 取消键
* ------------------------------------------------------------------------------
*/
//Initialize global variables
(function () {
var params = PluginManager.parameters("yang1zhi_esc");
var name = String(params["Pic Name"]);
var esc_width = Number(params["Pic Width"]);
var esc_height = Number(params["Pic Height"]);
var right_edge = Number(params["Right Edge"]);
var up_edge = Number(params["Up Edge"]);
Scene_Map.prototype.isMapTouchOk = function() {
if (this.is_NOmove_window()) {return false}
return this.isActive() && $gamePlayer.canMove();
};
//点击后不会移动的窗口
Scene_Map.prototype.is_NOmove_window = function() {
//ESC窗口
if (SceneManager._scene._escWindow.containsPoint({x: TouchInput.x, y: TouchInput.y})) {return true}
return false
}
ESC_SELECTABLE_UPDATE = Window_Selectable.prototype.update
Window_Selectable.prototype.update = function() {
ESC_SELECTABLE_UPDATE.call(this);
this.CancelCancel(); //取消键
};
Window_Selectable.prototype.CancelCancel = function() {
//不活动的窗口跳过
if (!SceneManager._scene._escWindow) {return}
//不活动的窗口跳过
if (!this.isOpenAndActive()) {return}
//当按下鼠标左键
if (this.isCancelEnabled() && TouchInput.isTriggered('ok')) {
//当鼠标X在取消键范围内
if (SceneManager._scene._escWindow.containsPoint({x: TouchInput.x, y: TouchInput.y})) {
this.processCancel();
}
}
};
ESC_DISPLAYOBJECTS = Scene_Map.prototype.createDisplayObjects
Scene_Map.prototype.createDisplayObjects = function() {
ESC_DISPLAYOBJECTS.call(this);
this.createescWindow(); //ESC键
};
ESC_MENUBASE_SREATE = Scene_MenuBase.prototype.create
Scene_MenuBase.prototype.create = function() {
ESC_MENUBASE_SREATE.call(this);
this.createescWindow(); //ESC键
};
Scene_Base.prototype.createescWindow = function() {
this._escWindow = new Window_esc(Graphics.width- esc_width - right_edge,up_edge,esc_width,esc_height,this.constructor.name);
this.addChild(this._escWindow);
};
Scene_Base.prototype.onESCOk = function() {
//Scene_Map.isActive()
this._escWindow.activate();
if (this.constructor.name == 'Scene_Map') {SceneManager.push(Scene_Menu);}
};
//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//显示特效图片----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function Window_esc() {
this.initialize.apply(this, arguments);
}
Window_esc.prototype = Object.create(Sprite.prototype);
Window_esc.prototype.constructor = Window_esc;
Window_esc.prototype.initialize = function(x, y,w,h,name) {
Sprite.prototype.initialize.call(this);
this._sc_name = name
var ww = w || 32
var hh = h || 32
this.move(x,y)
this.contents = new Sprite(new Bitmap(ww, hh));
this.addChild(this.contents);
this.bitmap = ImageManager.loadSystem('ESC');
};
Window_esc.prototype.update = function() {
Sprite.prototype.update.call(this);
//不在地图上跳过
if (this._sc_name != 'Scene_Map') {return}
//当按下鼠标左键
if (TouchInput.isTriggered('ok')) {
//当鼠标X在取消键范围内
if (this.containsPoint({x: TouchInput.x, y: TouchInput.y})) {
//演奏SE
SoundManager.playSystemSound(1);
SceneManager.push(Scene_Menu);
}
}
};
Window_esc.prototype.show = function() {
this.visible = this.contents.visible = true;
};
Window_esc.prototype.hide = function() {
this.visible = this.contents.visible = false;
};
Window_esc.prototype.setAnchor = function (ax, ay) {
this.anchor.x = this.contents.anchor = ax;
this.anchor.y = this.contents.anchor = ay;
};
Window_esc.prototype.clear = function() {
this.contents.bitmap.clear();
};
Window_esc.prototype.drawIcon = function(iconIndex, x, y) {
var bitmap = ImageManager.loadSystem('IconSet');
var sx = iconIndex % 16 * esc_width;
var sy = Math.floor(iconIndex / 16) * esc_width;
this.contents.bitmap.blt(bitmap, sx, sy, esc_width, esc_height, x, y);
};
})();
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1