//这个窗口构造,设置了“属性”、“武器”、“装备”、"能力"一共四个选项
//继承窗口
function Window_OriginBase() {
this.initialize(...arguments);
}
Window_OriginBase.prototype = Object.create(Window_Command.prototype);
Window_OriginBase.prototype.constructor = Window_OriginBase;
//设置透明度和边框大小
Window_OriginBase.prototype.initialize = function(rect) {
Window_Command.prototype.initialize.call(this,rect);
this.opacity = 0;
this.padding = 0;
}
//设置选项最大列数
Window_OriginBase.prototype.maxCols = function() {
return 4;
};
//设置选项
Window_OriginBase.prototype.makeCommandList = function() {
if (this.needsCommand("attr")) {
this.addCommand("属性", "attr");
}
if (this.needsCommand("weapon")) {
this.addCommand("武器", "weapon");
}
if (this.needsCommand("equip")) {
this.addCommand("装备", "equip");
}
if (this.needsCommand("ability")) {
this.addCommand("能力", "ability");
}
};
//参考游戏原来的库摘抄的,作用好像是判断在原本游戏里有没有这个选项?
Window_OriginBase.prototype.needsCommand = function(name) {
const table = ["attr", "weapon", "equip", "ability"];
const index = table.indexOf(name);
if (index >= 0) {
return $dataSystem.itemCategories[index];
}
return true;
};
//对应的场景
function Scene_Origin() {
this.initialize(...arguments);
}
//基本
Scene_Origin.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Origin.prototype.constructor = Scene_Origin;
Scene_Origin.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
ImageManager.loadBitmap("img/pictures/","SaveBg04");
};
//创建场景
Scene_Origin.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createCommandWindow();
};
Scene_Origin.prototype.createCommandWindow = function() {
const rect = this.commandWindowRect();
this.win = new Window_OriginBase(rect);
//通过this.drawBg(rect)给窗口添加一个精灵,能够显示图片。
this.drawBg(rect);
//返回按钮
this.win.setHandler("cancel", this.popScene.bind(this));
//添加
this.addWindow(this.win);
};
//尺寸
Scene_Origin.prototype.commandWindowRect = function() {
const ww = Graphics.width*0.45;
const wh = Graphics.height*0.1;
const wx = Graphics.width*0.5;
const wy = Graphics.height*0.8;
return new Rectangle(wx, wy, ww, wh);
};
//设置图片的函数
Scene_Origin.prototype.drawBg = function(rect) {
//新建精灵
const sprite_origin = new Sprite();
sprite_origin.bitmap = ImageManager.loadBitmap("img/pictures/","SaveBg04");
//通过回调确保图片顺利加载
sprite_origin.bitmap.addLoadListener(function(){
//自适应宽高
sprite_origin.scale.x = rect.width/sprite_origin.bitmap.width;
sprite_origin.scale.y = rect.height/sprite_origin.bitmap.height;
}.bind(this));
//添加
this.win.addChild(sprite_origin);
};