赞
踩
继续水点内容
现在发出及确认物品窗口显示及操作。
function Window_BattleItem() { this.initialize.apply(this, arguments); } Window_BattleItem.prototype = Object.create(Pal_Window_ItemList.prototype); Window_BattleItem.prototype.constructor = Window_BattleItem; Window_BattleItem.prototype.initialize = function(x, y, width, height) { Pal_Window_ItemList.prototype.initialize.call(this, x, y, width, height); this.hide(); }; Window_BattleItem.prototype.includes = function(item) { return $gameParty.canUse(item); }; Window_BattleItem.prototype.show = function() { this.selectLast(); this.showHelpWindow(); Pal_Window_ItemList.prototype.show.call(this); }; Window_BattleItem.prototype.hide = function() { this.hideHelpWindow(); Pal_Window_ItemList.prototype.hide.call(this); };
这里和法术窗口是一样的继承了之前的窗口。
Pal_Scene_Battle.prototype.createItemWindow = function() {
this._itemWindow = new Window_BattleItem(39, 169, 561, 213);
this._itemWindow.setHelpWindow(this._helpWindow);
this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
this.addChild(this._itemWindow);
};
创建物品战斗窗口。
Pal_Scene_Battle.prototype.commandItem = function() {
this._skillBackgroundSprite.visible=true;
this._skillHelpBackgroundSprite.visible=true;
this._itemWindow.refresh();
this._itemWindow.show();
this._itemWindow.activate();
};
打开物品窗口,并显示背景。
Pal_Scene_Battle.prototype.onActorCancel = function() { this._actorWindow.hide(); if(this._actorCommandWindow.currentSymbol()==='skill'){ this._skillBackgroundSprite.visible=true; this._skillHelpBackgroundSprite.visible=true; this._skillWindow.show(); this._skillWindow.activate(); } if(this._itemCommandWindow.currentSymbol()==='use'){ this._skillBackgroundSprite.visible=true; this._skillHelpBackgroundSprite.visible=true; this._itemWindow.show(); this._itemWindow.activate(); } }; Pal_Scene_Battle.prototype.onEnemyCancel = function() { this._enemyWindow.hide(); if(this._actorCommandWindow.currentSymbol()==='attack'){ this._actorCommandWindow.activate(); } if(this._actorCommandWindow.currentSymbol()==='skill'){ this._skillBackgroundSprite.visible=true; his._skillHelpBackgroundSprite.visible=true; this._skillWindow.show(); this._skillWindow.activate(); } if(this._itemCommandWindow.currentSymbol()==='use'){ this._skillBackgroundSprite.visible=true; this._skillHelpBackgroundSprite.visible=true; this._itemWindow.show(); this._itemWindow.activate(); } }; Pal_Scene_Battle.prototype.onSelectAction = function() { var action = BattleManager.inputtingAction(); this._skillWindow.hide(); this._itemWindow.hide(); if (!action.needsSelection()) { this.selectNextCommand(); } else if (action.isForOpponent()) { this.selectEnemySelection(); } else { this.selectActorSelection(); } };
这三个方法是在使用物品或使用法术时调用的。
onSelectAction 方法中判断了目标对象的操作,因此在判断前,将法术及物品的战斗窗口均进行隐藏。
onActorCancel 和 onEnemyCancel 角色和敌人选择的取消方法法术及物品使用上之前是switch语句进行判断的,但为了仿仙剑的一致性,因此将处理了这些方法操作,开启对应的背景,但麻烦来了,每个操作的标志默认判断是传入的角色的战斗指令操作,这样就会导致能使用法术的,但物品的就判断不了,因此将switch语句改成多个if判断,这样就能根据需要的内容进行处理了。
Pal_Scene_Battle.prototype.onItemOk = function() { this._skillBackgroundSprite.visible=false; this._skillHelpBackgroundSprite.visible=false; this._itemCommandWindow.hide(); this._otherCommandWindow.hide(); var item = this._itemWindow.item(); var action = BattleManager.inputtingAction(); action.setItem(item.id); $gameParty.setLastItem(item); this.onSelectAction(); }; Pal_Scene_Battle.prototype.onItemCancel = function() { this._skillBackgroundSprite.visible=false; this._skillHelpBackgroundSprite.visible=false; this._itemCommandWindow.show(); this._otherCommandWindow.show(); this.startItemCommandSelection(); this._itemWindow.hide(); };
物品的使用及取消物品战斗菜单,这里着重说下取消的,里面调用了开始物品命令选择的方法,这是为了能够正常的跳转回物品战斗的指令窗口,和原版游戏的操作保持一致。
这样的基本的UI效果和操作的效果就出来了!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。