创建窗口范例(RMMZ)

//==========================================
//0.插件的信息部分
//==========================================
/*:
 * @target MZ
 * @plugindesc 创建窗口实作
 * @author 古树旋律
 *
 * @help
 * 1.复制初始化部分
 * 2.书写要更新的部分,里面添加展示的内容
 * 3.添加更新并启用
 * 4.设置窗口的位置和尺寸
 * 5.创建调用函数
 * 6.复写需要调用窗口的场景
 */

//==========================================
//1.初始化部分
//==========================================
function Window_DIYWindow() {
    this.initialize(...arguments);
}
Window_DIYWindow.prototype = Object.create(Window_Base.prototype);
Window_DIYWindow.prototype.constructor = Window_DIYWindow;
Window_DIYWindow.prototype.initialize = function (rect) {
    Window_Base.prototype.initialize.call(this, rect);
    this.opacity = 0;
    this.refresh();//刷新调用
};

//==========================================
//2.更新部分,里面添加展示的内容
//==========================================
Window_DIYWindow.prototype.refresh = function () {
    this.contents.clear();//清除旧内容
    const date = new Date();
    this.contents.fontSize = 28;//字体大小
    this.drawText(date, 0, 0, 750, 'left');//展示
    //括号内为(内容,X坐标,Y坐标,内容宽度,对齐方式)
};

//==========================================
//3.添加更新并启用
//==========================================
Window_DIYWindow.prototype.update = function () {
    Window_Base.prototype.update.call(this);
    this.refresh();
};

//==========================================
//4.设置窗口的位置和尺寸
//==========================================
Scene_Base.prototype.DIYWindowRect = function () {
    const wx = 0;
    const wy = 0;
    const ww = 750;
    const wh = 200;
    return new Rectangle(wx, wy, ww, wh);
    //括号内为(X坐标、Y坐标、窗体宽度、窗体高度)
};

//==========================================
//5.创建调用函数
//==========================================
Scene_Base.prototype.createDIYWindow = function () {
    const rect = this.DIYWindowRect();
    this._DIYWindow = new Window_DIYWindow(rect);
    this.addChild(this._DIYWindow);
};

//==========================================
//6.复写需要调用的场景
//==========================================
var _Scene_Map_createAllWindows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function () {
    _Scene_Map_createAllWindows.call(this);
    this.createDIYWindow();
};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值