RMMV 仿新仙剑奇侠传1 装备菜单展示 01
原版游戏效果
这个界面是不是很熟悉,这不就是物品界面嘛!只不过这个物品界面中只有武器和装备(衣服、首饰等等)。
可以进行装备的物品,光标会指向正好可以进行穿戴显示的位置,并在右边用箭头指向变化的数值,有点炒股的感觉,红的提升,绿的下降。
若是不能装备的角色会没有对应的光标并显示一段文字然后消失。
这里由于是需要进行数据的修改及参考,暂时不做出来,先将简单的前两个操作完成。
RMMV原版效果
RMMV中直接分成五个窗口,人物状态窗口,装备选项窗口,物品窗口,装备子项窗口,装备说明窗口。
这里物品窗口由于之前搞测试的缘故,因此将透明度降低了,现代化的窗口结构其实已经很不错了,不管是功能还是操作上其实都比老游戏的效果好,更一目了然,不过仿老游戏的话,那功能和UI上保持风格的一致会更好,而且也处理了下说明文字的问题。
仿新仙剑装备场景及菜单
下面将开始进行新仙剑的装备场景和菜单的简单模仿。
创建装备场景及添加装备菜单
由于装备菜单和物品及法术菜单大体一致,因此先将对应的场景和菜单复制一份,修改成装备的。效果如下图:
可以看到所显示出来的物品全是武器装备了,但是如何才显示武器和装备的呢?答案就是物品菜单中的 includes 方法。
Pal_Window_EquipItem.prototype.includes = function(item) {
return DataManager.isWeapon(item)||DataManager.isArmor(item);
};
物品装备窗口中的 includes 方法用来确定物品的类型,里面将对应的判断及操作简短成返回用 DataManager 中的武器及装备的判断来确认是否是需要的物品,是就进行返回,这样就得到了我们需要的效果。
添加人物装备状态栏
这个是如何实现的呢?
首先是装备状态的背景,由于不想在菜单中做,因此将其放到了背景中。
Pal_Scene_Equip.prototype.createItemWindowBackground = function() {
var equipBackground= ImageManager.loadSystem("EquipDataBg");//获取装备信息背景图片
this._equipBackgroundSprite=new Sprite(equipBackground);//将图片精灵给背景
this._equipBackgroundSprite.x=8;
this._equipBackgroundSprite.y=150;
this._equipBackgroundSprite.setFrame(0, 0, 624, 256);
this._equipBackgroundSprite.visible=false;
this.addChild(this._equipBackgroundSprite);//将图片给菜单场景子对象
};
可以看到我添加了一张名称是装备数据的背景图片,并设置显示为不可显示。
那数据怎么来呢?
Pal_Scene_Equip.prototype.createStatusWindow = function() {
this._statusWindow = new Pal_Window_EquipStatus(39, 169, 561, 213);
this.addChild(this._statusWindow);
};
添加了装备状态的窗口,并让它创建的比装备物品窗口早。 (后面简称装备物品为物品) 并在物品窗口中的物品选项的方法中修改对应的操作。
Pal_Scene_Equip.prototype.onItemOk = function() {
SoundManager.playEquip();
var hide=this.children[3];
this.children[3]=this.children[5];
this.children[5]=hide;
this._equipItemBackgroundSprite.visible=false;
this._itemWindow.visible=false;
this._equipBackgroundSprite.visible=true;
$gameParty.setLastItem(this.item());
this.determineItem();
};
打开之后就是装备状态窗口了,之后的显示呢?
对应的显示在窗口之中进行绘制,代码如下:
function Pal_Window_EquipStatus() {
this.initialize.apply(this, arguments);
}
Pal_Window_EquipStatus.prototype = Object.create(Window_Base.prototype);
Pal_Window_EquipStatus.prototype.constructor = Pal_Window_EquipStatus;
Pal_Window_EquipStatus.prototype.initialize = function(x, y, width, height) {
var width = width;
var height = height;
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._actor = null;
this._tempActor = null;
this._numRightArrow=ImageManager.loadSystem('BigNumberRightArrow');
this._bigRightArrow=ImageManager.loadSystem('BigRightArrow');
this.refresh();
};
Pal_Window_EquipStatus.prototype.spacing = function() {
return 0;
};
Pal_Window_EquipStatus.prototype.standardPadding = function() {
return 0;
};
Pal_Window_EquipStatus.prototype.setActor = function(actor) {
if (this._actor !== actor) {
this._actor = actor;
this.refresh();
}
};
Pal_Window_EquipStatus.prototype.refresh = function() {
this.contents.clear();
this.drawItem(0, 0);
};
Pal_Window_EquipStatus.prototype.setTempActor = function(tempActor) {
if (this._tempActor !== tempActor) {
this._tempActor = tempActor;
this.refresh();
}
};
Pal_Window_EquipStatus.prototype.drawItem = function(x, y, paramId) {
//暂时的UI
this.drawEquipTargetArrow(y);//,etypeId
this.drawEquipName(y);
this.drawCurrentParam();
this.drawRightArrow();
this.drawNewParam();
};
Pal_Window_EquipStatus.prototype.drawEquipTargetArrow = function(y, etypeId) {
var bitmap =this._bigRightArrow;
this.contents.blt(bitmap, 0, 0, 32, 44, -4, 8);//系数32
this.contents.blt(bitmap, 0, 0, 32, 44, -4, 40);
this.contents.blt(bitmap, 0, 0, 32, 44, -4, 72);
this.contents.blt(bitmap, 0, 0, 32, 44, -4, 104);
this.contents.blt(bitmap, 0, 0, 32, 44, -4, 136);
this.contents.blt(bitmap, 0, 0, 32, 44, -4, 168);
};
Pal_Window_EquipStatus.prototype.drawEquipName = function(y, etypeId) {
this.contents.fontSize=18;
this.contents.fontFace="WangJianti";
this.drawText("测试装备名称", 110, 14, 110, 'left');
this.drawText("测试装备名称", 110, 46, 110, 'left');
this.drawText("测试装备名称", 110, 78, 110, 'left');
this.drawText("测试装备名称", 110, 110, 110, 'left');
this.drawText("测试装备名称", 110, 142, 110, 'left');
this.drawText("测试装备名称", 110, 174, 110, 'left');
};
Pal_Window_EquipStatus.prototype.drawCurrentParam = function(x, y, paramId) {
this.changeTextColor(this.systemColor());
this.drawText("99999", 400, 14, 110, 'left');
this.drawText("99999", 400, 46, 110, 'left');
this.drawText("99999", 400, 78, 110, 'left');
this.drawText("99999", 400, 110, 110, 'left');
this.drawText("99999", 400, 142, 110, 'left');
this.drawText("99999", 400, 174, 110, 'left');
};
Pal_Window_EquipStatus.prototype.drawRightArrow = function(x, y) {
var bitmap =this._numRightArrow;
this.contents.blt(bitmap, 0, 0, 47, 28, 448, 18);//系数32
this.contents.blt(bitmap, 0, 0, 47, 28, 448, 50);
this.contents.blt(bitmap, 0, 0, 47, 28, 448, 72);
this.contents.blt(bitmap, 0, 0, 47, 28, 448, 104);
this.contents.blt(bitmap, 0, 0, 47, 28, 448, 136);
this.contents.blt(bitmap, 0, 0, 47, 28, 448, 168);
};
Pal_Window_EquipStatus.prototype.drawNewParam = function(x, y, paramId) {
this.drawText("99999", 500, 14, 110, 'left');
this.drawText("99999", 500, 46, 110, 'left');
this.drawText("99999", 500, 78, 110, 'left');
this.drawText("99999", 500, 110, 110, 'left');
this.drawText("99999", 500, 142, 110, 'left');
this.drawText("99999", 500, 174, 110, 'left');
};
现在可以看到该代码属于一个静态的展示,窗口背景没有隐藏,文字没有修改对应的颜色,人物数据没有添加上,下一步就开始这部分的操作。
小结
游戏开发是一件趣事,但有时可能也是一件痛苦的事,有时还真觉得放弃算了,但想到之前的计划和自己的梦想,还是想继续坚持下,虽然这一个不算是正式的开发吧!!!
这次的开发梳理了之前遇到的或看到的各种难题和代码,也是解决了不少的问题不过由于暂时不考虑对应的优化等,因此先做个简单的demo才是最好的!
预告
由于篇幅有限下一篇会完成整个简单装备场景的搭建,现在的搭建一个具备了功能的雏形了,但还少了对应的真实的数据和有效的操作。。。