赞
踩
原仙剑战斗指令菜单是使用方向键控制,同时按照使用情况正好对应四个指令和四个方向,同时没有选中的菜单用黑色透明图片覆盖,达到未选中的效果,红色图片表示不能进行选中(即不能使用)。
通过该图可以清楚的看到未选中及选中、不能选中的情况;同时可以看到其他指令菜单的位置也算是做一下绝对的定位。
战斗时,分配键盘上Up键对应攻击,Down键对应其他,Left键对应法术,Right键对应合击。
function Window_ActorCommand() { this.initialize.apply(this, arguments); } Window_ActorCommand.prototype = Object.create(Window_Command.prototype); Window_ActorCommand.prototype.constructor = Window_ActorCommand; Window_ActorCommand.prototype.initialize = function() { var y = Graphics.boxHeight - this.windowHeight(); Window_Command.prototype.initialize.call(this, 0, y); this.openness = 0; this.deactivate(); this._actor = null; }; Window_ActorCommand.prototype.windowWidth = function() { return 192; }; Window_ActorCommand.prototype.numVisibleRows = function() { return 4; }; //创建命令列表 Window_ActorCommand.prototype.makeCommandList = function() { if (this._actor) { this.addAttackCommand(); this.addSkillCommands(); this.addJointAttackCommand(); this.addOtherCommand(); } }; //添加攻击命令 Window_ActorCommand.prototype.addAttackCommand = function() { this.addCommand(TextManager.attack, 'attack', this._actor.canAttack()); }; //添加魔法命令 Window_ActorCommand.prototype.addSkillCommands = function() { var skillTypes = this._actor.addedSkillTypes(); skillTypes.sort(function(a, b) { return a - b; }); skillTypes.forEach(function(stypeId) { var name = $dataSystem.skillTypes[stypeId]; this.addCommand(name, 'skill', true, stypeId); }, this); }; //添加合击命令 Window_ActorCommand.prototype.addJointAttackCommand = function() { this.addCommand("合击", 'jointAttack', this._actor.canAttack()); }; //添加其他命令 Window_ActorCommand.prototype.addOtherCommand = function() { this.addCommand("其他", 'other'); }; Window_ActorCommand.prototype.setup = function(actor) { this._actor = actor; this.clearCommandList(); this.makeCommandList(); this.refresh(); this.selectLast(); this.activate(); this.open(); }; Window_ActorCommand.prototype.processOk = function() { if (this._actor) { if (ConfigManager.commandRemember) { this._actor.setLastCommandSymbol(this.currentSymbol()); } else { this._actor.setLastCommandSymbol(''); } } Window_Command.prototype.processOk.call(this); }; Window_ActorCommand.prototype.selectLast = function() { this.select(0); if (this._actor && ConfigManager.commandRemember) { var symbol = this._actor.lastCommandSymbol(); this.selectSymbol(symbol); if (symbol === 'skill') { var skill = this._actor.lastBattleSkill(); if (skill) { this.selectExt(skill.stypeId); } } } }; //-------------------------------------------------------------- //光标向下 Window_ActorCommand.prototype.cursorDown = function(wrap) { if(wrap){ this.select(3); } }; //光标向上 Window_ActorCommand.prototype.cursorUp = function(wrap) { if(wrap){ this.select(0); } }; //光标向右 Window_ActorCommand.prototype.cursorRight = function(wrap) { if(wrap){ this.select(2); } }; //光标向左 Window_ActorCommand.prototype.cursorLeft = function(wrap) { if(wrap){ this.select(1); } };
这里进行了简化,四个按键操作原来需要获取指令序号及指令的数量后计算下一个操作的指令,现在全部简化为,判断是否按下对应按键,就执行对应的指令。
Window_ActorCommand.prototype.initialize = function() { ...... this.move(12, 344, 148, 130); this.BattleCommand= ImageManager.loadSystem('FightCommand'); ...... this.refresh(); }; //标准内边距 Window_ActorCommand.prototype.standardPadding = function() { return 0; }; Window_ActorCommand.prototype._refreshCursor = function() { }; Window_ActorCommand.prototype._updateCursor = function() { }; Window_ActorCommand.prototype.update=function(){ Window_Command.prototype.update.call(this); this.refresh(); } Window_ActorCommand.prototype.refresh = function() { this.contents.clear(); if(this._actor){ this.drawBattleActorCommand(); } }; Window_ActorCommand.prototype.drawBattleActorCommand = function() { var bitmap=this.BattleCommand; this.contents.paintOpacity=255; this.contents.blt(bitmap, 0, this._list[0].enabled?0:56, 56, 56, 46, 0); this.contents.blt(bitmap, 112, this._list[3].enabled?0:56, 56, 56, 46, 73); this.contents.blt(bitmap, 168, this._list[1].enabled?0:56, 56, 56, 0, 37); this.contents.blt(bitmap, 56, this._list[2].enabled?0:56, 56, 56, 91, 37); this.contents.paintOpacity=120; switch(this._index){ case 0: if(this._list[3].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 46, 73); if(this._list[1].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 0, 37); if(this._list[2].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 91, 37); break; case 1: if(this._list[0].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 46, 0); if(this._list[3].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 46, 73); if(this._list[2].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 91, 37); break; case 2: if(this._list[0].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 46, 0); if(this._list[3].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 46, 73); if(this._list[1].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 0, 37); break; case 3: if(this._list[0].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 46, 0); if(this._list[1].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 0, 37); if(this._list[2].enabled)this.contents.blt(bitmap, 0, 112, 56, 56, 91, 37); break; case -1: break; } }; //光标向下 Window_ActorCommand.prototype.cursorDown = function(wrap) { if(wrap&&this._list[3].enabled){ this.select(3); } };
_refreshCursor 和 _updateCursor 方法由于是处理光标的因此用空的方法去掉对应的光标; drawBattleActorCommand 方法是进行绘制战斗指令图标的,其流程是绘制基础战斗指令的图标,通过三元运算符判断绘制的图片是启用还是未启用的,后面是绘制图标的遮挡的。选中的图标和未启用的图标不会被进行遮挡; cursorDown 方法和另外三个方法进行了一定的修改,即未启用的指令是不会被选中的; refresh 和 update方法分别是进行更新和刷新指令图标的,这样后期若是需要人物不能操作时就可以实现效果。
基础战斗菜单就已完成,之后将制作其他指令的中的二级和三级菜单。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。