【RPG Maker MV 仿新仙剑 战斗场景UI (一)】

news/2024/5/18 14:17:46 标签: ui, javascript, 游戏程序, 游戏

RPG Maker MV 仿新仙剑 战斗场景UI 一

  • 战斗场景制作
    • 原版仙剑战斗UI
    • 原版RPG Maker MV战斗UI
    • 启航
      • 战斗菜单

战斗场景制作

RPG Maker 中战斗场景的UI是比较经典的日式RPG的UI布局,现在尝试将它变成仙剑这样的布局看看。。。

原版仙剑战斗UI

这里只截图了开始的战斗UI其余部分会在制作时放出
原版仙剑战斗UI

原版RPG Maker MV战斗UI

RMMV战斗UI
初始看着还是挺简陋的,当然现在是没有开启侧视战斗场景的。
侧视战斗
从这里就可以看出需要改的地方有不少了。
有个问题,由于之前法术的菜单已经修改了,因此使用会进行报错,需要进行名称的修改,虽然在法术的场景中是正常的,但在战斗的法术中就会出现错误找不到对应的初始化方法,这应该就是名称导致的解释器找不到对应的方法,因为继承时是按照原有的类进行继承的,所以需要进行名称上的变更,这点也是通过好几次调试发现就是过不去才想起来的!!!
由于涉及到的窗口过多,因此进行分场景及窗口来进行更新吧!

启航

战斗的菜单可以简单划分为战斗指令菜单、额外战斗指令菜单、物品操作菜单、人物状态菜单这几项,另外的物品使用、物品装备、法术使用、物品投掷、人物具体状态菜单等,可以用额外场景进行实现或后期修改对应的菜单项完成UI操作。

战斗菜单

战斗指令菜单中有攻击、合击、法术、其他,这四个选项,其中合击是优先级最高的操作,后期会进行正式战斗的测试时进行完善,现在只会用于普通攻击的操作。
初期完成菜单图片:
战斗指令
战斗场景代码:

javascript">function Pal_Scene_Battle() {
    this.initialize.apply(this, arguments);
}
Pal_Scene_Battle.prototype = Object.create(Scene_Base.prototype);
Pal_Scene_Battle.prototype.constructor = Pal_Scene_Battle;

Pal_Scene_Battle.prototype.initialize = function() {
    Scene_Base.prototype.initialize.call(this);
};
Pal_Scene_Battle.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this.createDisplayObjects();
};
Pal_Scene_Battle.prototype.start = function() {
    Scene_Base.prototype.start.call(this);
    this.startFadeIn(this.fadeSpeed(), false);
    BattleManager.playBattleBgm();
    BattleManager.startBattle();
};
Pal_Scene_Battle.prototype.update = function() {
    var active = this.isActive();
    $gameTimer.update(active);
    $gameScreen.update();
    this.updateStatusWindow();
    this.updateWindowPositions();
    if (active && !this.isBusy()) {
        this.updateBattleProcess();
    }
    Scene_Base.prototype.update.call(this);
};
/** 更新作战流程
 * 
 */
Pal_Scene_Battle.prototype.updateBattleProcess = function() {
    if (!this.isAnyInputWindowActive() || BattleManager.isAborting() ||
            BattleManager.isBattleEnd()) {
        BattleManager.update();
        this.changeInputWindow();
    }
};
/** 是否有任何输入窗口处于活动状态
 * 
 */
Pal_Scene_Battle.prototype.isAnyInputWindowActive = function() {
    return (this._partyCommandWindow.active ||
            this._actorCommandWindow.active ||
            this._skillWindow.active ||
            this._itemWindow.active ||
            this._actorWindow.active ||
            this._enemyWindow.active);
};
/** 更改输入窗口
 *  
 */
Pal_Scene_Battle.prototype.changeInputWindow = function() {
    if (BattleManager.isInputting()) {
        if (BattleManager.actor()) {
            this.startActorCommandSelection();
        } else {
            this.startPartyCommandSelection();
        }
    } else {
        this.endCommandSelection();
    }
};

//停止
Pal_Scene_Battle.prototype.stop = function() {
    Scene_Base.prototype.stop.call(this);
    if (this.needsSlowFadeOut()) {
        this.startFadeOut(this.slowFadeSpeed(), false);
    } else {
        this.startFadeOut(this.fadeSpeed(), false);
    }
    this._statusWindow.close();
    this._partyCommandWindow.close();
    this._actorCommandWindow.close();
};
/** 结束战斗
 * 
 */
Pal_Scene_Battle.prototype.terminate = function() {
    Scene_Base.prototype.terminate.call(this);
    $gameParty.onBattleEnd();
    $gameTroop.onBattleEnd();
    AudioManager.stopMe();
    ImageManager.clearRequest();
};

//需要慢速淡出
Pal_Scene_Battle.prototype.needsSlowFadeOut = function() {
    return (SceneManager.isNextScene(Scene_Title) ||
            SceneManager.isNextScene(Scene_Gameover));
};

//更新状态窗口
Pal_Scene_Battle.prototype.updateStatusWindow = function() {
    if ($gameMessage.isBusy()) {
        this._statusWindow.close();
        this._partyCommandWindow.close();
        this._actorCommandWindow.close();
    } else if (this.isActive() && !this._messageWindow.isClosing()) {
        this._statusWindow.open();
    }
};

//更新窗口位置
Pal_Scene_Battle.prototype.updateWindowPositions = function() {
    var statusX = 0;
    if (BattleManager.isInputting()) {
        statusX = this._partyCommandWindow.width;
    } else {
        statusX = this._partyCommandWindow.width / 2;
    }
    if (this._statusWindow.x < statusX) {
        this._statusWindow.x += 16;
        if (this._statusWindow.x > statusX) {
            this._statusWindow.x = statusX;
        }
    }
    if (this._statusWindow.x > statusX) {
        this._statusWindow.x -= 16;
        if (this._statusWindow.x < statusX) {
            this._statusWindow.x = statusX;
        }
    }
};
/** 创建显示对象
 * 
 */
Pal_Scene_Battle.prototype.createDisplayObjects = function() {
    this.createSpriteset();
    this.createWindowLayer();
    this.createAllWindows();
    BattleManager.setLogWindow(this._logWindow);
    BattleManager.setStatusWindow(this._statusWindow);
    BattleManager.setSpriteset(this._spriteset);
    this._logWindow.setSpriteset(this._spriteset);
};
/** 创建精灵集
 * 
 */
Pal_Scene_Battle.prototype.createSpriteset = function() {
    this._spriteset = new Spriteset_Battle();
    this.addChild(this._spriteset);
};
/** 创建全部战斗窗口
 * 
 */
Pal_Scene_Battle.prototype.createAllWindows = function() {
    this.createLogWindow();
    this.createStatusWindow();
    this.createPartyCommandWindow();		
    this.createActorCommandWindow();		
    this.createHelpWindow();
    this.createSkillWindow();
    this.createItemWindow();
    this.createActorWindow();
    this.createEnemyWindow();
    this.createMessageWindow();
    this.createScrollTextWindow();
};
/** 创建战斗日志窗口
 * 
 */
Pal_Scene_Battle.prototype.createLogWindow = function() {
    this._logWindow = new Window_BattleLog();
    this.addWindow(this._logWindow);
};
/** 创建战斗状态窗口
 * 
 */
Pal_Scene_Battle.prototype.createStatusWindow = function() {
    this._statusWindow = new Window_BattleStatus();
    this.addWindow(this._statusWindow);
};
/** 创建队伍战斗命令窗口
 * 
 */
Pal_Scene_Battle.prototype.createPartyCommandWindow = function() {
    this._partyCommandWindow = new Window_PartyCommand();
    this._partyCommandWindow.setHandler('fight',  this.commandFight.bind(this));//战斗
    this._partyCommandWindow.setHandler('escape', this.commandEscape.bind(this));//撤退
    this._partyCommandWindow.deselect();//取消选择
    this.addWindow(this._partyCommandWindow);
};
/** 创建角色战斗命令窗口
 * 
 */
Pal_Scene_Battle.prototype.createActorCommandWindow = function() {
    this._actorCommandWindow = new Window_ActorCommand();
    this._actorCommandWindow.setHandler('attack', this.commandAttack.bind(this));
    this._actorCommandWindow.setHandler('skill',  this.commandSkill.bind(this));
    this._actorCommandWindow.setHandler('jointAttack',  this.commandJointAttack.bind(this));
    this._actorCommandWindow.setHandler('other',   this.commandOther.bind(this));
    this.addWindow(this._actorCommandWindow);
};
/** 创建战斗帮助窗口
 *  
 */
Pal_Scene_Battle.prototype.createHelpWindow = function() {
    this._helpWindow = new Window_Help();
    this._helpWindow.visible = false;
    this.addWindow(this._helpWindow);
};
/** 创建魔法战斗窗口
 * 
 */
Pal_Scene_Battle.prototype.createSkillWindow = function() {
    var wy = this._helpWindow.y + this._helpWindow.height;
    var wh = this._statusWindow.y - wy;
    this._skillWindow = new Window_BattleSkill(0, wy, Graphics.boxWidth, wh);
    this._skillWindow.setHelpWindow(this._helpWindow);
    this._skillWindow.setHandler('ok',     this.onSkillOk.bind(this));
    this._skillWindow.setHandler('cancel', this.onSkillCancel.bind(this));
    this.addWindow(this._skillWindow);
};
/** 创建物品战斗窗口
 * 
 */
Pal_Scene_Battle.prototype.createItemWindow = function() {
    var wy = this._helpWindow.y + this._helpWindow.height;
    var wh = this._statusWindow.y - wy;
    this._itemWindow = new Window_BattleItem(0, wy, Graphics.boxWidth, wh);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
    this.addWindow(this._itemWindow);
};
/** 创建战斗角色窗口
 * 
 */
Pal_Scene_Battle.prototype.createActorWindow = function() {
    this._actorWindow = new Window_BattleActor(0, this._statusWindow.y);
    this._actorWindow.setHandler('ok',     this.onActorOk.bind(this));
    this._actorWindow.setHandler('cancel', this.onActorCancel.bind(this));
    this.addWindow(this._actorWindow);
};
/** 创建战斗敌人窗口
 * @description 创建战斗敌人窗口
 * @
 */
Pal_Scene_Battle.prototype.createEnemyWindow = function() {
    this._enemyWindow = new Window_BattleEnemy(0, this._statusWindow.y);
    this._enemyWindow.x = Graphics.boxWidth - this._enemyWindow.width;
    this._enemyWindow.setHandler('ok',     this.onEnemyOk.bind(this));
    this._enemyWindow.setHandler('cancel', this.onEnemyCancel.bind(this));
    this.addWindow(this._enemyWindow);
};
/** 创建战斗消息窗口
 * 
 */
Pal_Scene_Battle.prototype.createMessageWindow = function() {
    this._messageWindow = new Window_Message();
    this.addWindow(this._messageWindow);
    this._messageWindow.subWindows().forEach(function(window) {
        this.addWindow(window);
    }, this);
};
/** 创建战斗滚动文本窗口
 * 
 */
Pal_Scene_Battle.prototype.createScrollTextWindow = function() {
    this._scrollTextWindow = new Window_ScrollText();
    this.addWindow(this._scrollTextWindow);
};
/** 刷新战斗状态
 * 
 */
Pal_Scene_Battle.prototype.refreshStatus = function() {
    this._statusWindow.refresh();
};
/** 开始队伍命令选择
 * 
 */
Pal_Scene_Battle.prototype.startPartyCommandSelection = function() {
    this.refreshStatus();
    this._statusWindow.deselect();
    this._statusWindow.open();
    this._actorCommandWindow.close();
    this._partyCommandWindow.setup();
};
//战斗命令
Pal_Scene_Battle.prototype.commandFight = function() {
    this.selectNextCommand();
};
//逃跑
Pal_Scene_Battle.prototype.commandEscape = function() {
    BattleManager.processEscape();
    this.changeInputWindow();
};
/** 开始角色命令选择
 * 
 */
Pal_Scene_Battle.prototype.startActorCommandSelection = function() {
    this._statusWindow.select(BattleManager.actor().index());
    this._partyCommandWindow.close();
    this._actorCommandWindow.setup(BattleManager.actor());
};
//攻击命令
Pal_Scene_Battle.prototype.commandAttack = function() {
    BattleManager.inputtingAction().setAttack();
    this.selectEnemySelection();
};
//魔法命令
Pal_Scene_Battle.prototype.commandSkill = function() {
    this._skillWindow.setActor(BattleManager.actor());
    this._skillWindow.setStypeId(this._actorCommandWindow.currentExt());
    this._skillWindow.refresh();
    this._skillWindow.show();
    this._skillWindow.activate();
};
//防御命令
Pal_Scene_Battle.prototype.commandJointAttack = function() {
    BattleManager.inputtingAction().setGuard();
    this.selectNextCommand();
};
//物品命令
Pal_Scene_Battle.prototype.commandOther = function() {
    this._itemWindow.refresh();
    this._itemWindow.show();
    this._itemWindow.activate();
};
/** 选择下一个命令
 * 
 */
Pal_Scene_Battle.prototype.selectNextCommand = function() {
    BattleManager.selectNextCommand();
    this.changeInputWindow();
};
//选择上一个命令
Pal_Scene_Battle.prototype.selectPreviousCommand = function() {
    BattleManager.selectPreviousCommand();
    this.changeInputWindow();
};
Pal_Scene_Battle.prototype.selectActorSelection = function() {
    this._actorWindow.refresh();
    this._actorWindow.show();
    this._actorWindow.activate();
};
Pal_Scene_Battle.prototype.onActorOk = function() {
    var action = BattleManager.inputtingAction();
    action.setTarget(this._actorWindow.index());
    this._actorWindow.hide();
    this._skillWindow.hide();
    this._itemWindow.hide();
    this.selectNextCommand();
};
Pal_Scene_Battle.prototype.onActorCancel = function() {
    this._actorWindow.hide();
    switch (this._actorCommandWindow.currentSymbol()) {
    case 'skill':
        this._skillWindow.show();
        this._skillWindow.activate();
        break;
    case 'item':
        this._itemWindow.show();
        this._itemWindow.activate();
        break;
    }
};
/** 选择敌人
 * 
 */
Pal_Scene_Battle.prototype.selectEnemySelection = function() {
    this._enemyWindow.refresh();
    this._enemyWindow.show();
    this._enemyWindow.select(0);
    this._enemyWindow.activate();
};
/** 敌人确定选择
 * 
 */
Pal_Scene_Battle.prototype.onEnemyOk = function() {
    var action = BattleManager.inputtingAction();
    action.setTarget(this._enemyWindow.enemyIndex());
    this._enemyWindow.hide();
    this._skillWindow.hide();
    this._itemWindow.hide();
    this.selectNextCommand();
};
/** 敌人取消选择
 * 
 */
Pal_Scene_Battle.prototype.onEnemyCancel = function() {
    this._enemyWindow.hide();
    switch (this._actorCommandWindow.currentSymbol()) {
    case 'attack':
        this._actorCommandWindow.activate();
        break;
    case 'skill':
        this._skillWindow.show();
        this._skillWindow.activate();
        break;
    case 'item':
        this._itemWindow.show();
        this._itemWindow.activate();
        break;
    }
};
Pal_Scene_Battle.prototype.onSkillOk = function() {
    var skill = this._skillWindow.item();
    var action = BattleManager.inputtingAction();
    action.setSkill(skill.id);
    BattleManager.actor().setLastBattleSkill(skill);
    this.onSelectAction();
};
Pal_Scene_Battle.prototype.onSkillCancel = function() {
    this._skillWindow.hide();
    this._actorCommandWindow.activate();
};
Pal_Scene_Battle.prototype.onItemOk = function() {
    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._itemWindow.hide();
    this._actorCommandWindow.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();
    }
};
Pal_Scene_Battle.prototype.endCommandSelection = function() {
    this._partyCommandWindow.close();
    this._actorCommandWindow.close();
    this._statusWindow.deselect();
};

相信大家的基础都是OK的,因此这些代码就不过多的赘述了,下一篇着重的介绍战斗指令菜单具体的效果及代码,包含战斗场景的一起贴出来。


http://www.niftyadmin.cn/n/5383666.html

相关文章

计算机网络常考面试题——PING命令

1.PING命令的作用 PING命令是一种常用的网络诊断工具&#xff0c;经常用来测试网络中主机之间的连通性和网络延迟。返回的信息包括目的主机的域名和IP地址、往返时间、丢包率等信息。 2.PING命令的工作原理 PING的原理基于网络层的ICMP互联网控制报文协议&#xff0c;主要原…

函数——递归3(c++)

求10097……41的值 问题描述 求 10097 ⋯ 41 的值。 输入 无。 输出 输出一行&#xff0c;即求到的和。 #include <bits/stdc.h> using namespace std; int aaa(int,int,int); int main() {cout<<aaa(1,100,0);return 0; } int aaa(int i,int n,int sum) {if…

【教程】N2N V3内网穿透、异地组网,包括Win/Linux/Android,包括不同内网实现adb远程连接

目录 一、背景 二、Linux 配置 并运行 N2N - Supernode (必选) 三、Linux -- 配置 并运行 N2N - 边缘节点配置 Edge(可选步骤) 四、Windows -- 配置 并运行 N2N - 边缘节点配置 Edge (可选步骤) (一)配置

【数据库_MySQL5.7.x】安装MySQL5.7.2*

开源软件的影响力 随着信息技术的快速发展&#xff0c;开源软件已经成为软件开发的趋势&#xff0c;并产生了深远的影响。开源软件的低成本、可协作性和透明度等特点&#xff0c;使得越来越多的企业和个人选择使用开源软件&#xff0c;促进了软件行业的繁荣。然而&#xff0c;…

[AIGC] 垃圾回收算法

垃圾回收算法 垃圾回收是一种自动化的内存管理方法。其核心目标是找出程序中不再使用的动态分配的内存块&#xff0c;并将其标记为可重用&#xff0c;以便能够进行新的内存分配。 下面我们将介绍三种主要的垃圾回收算法&#xff1a;标记清除算法、复制算法和标记压缩算法。 …

Vue的个人笔记

Vue学习小tips ctrl s ----> 运行 alt b <scrip> 链接 <script src"https://cdn.jsdelivr.net/npm/vue2.7.16/dist/vue.js"></script> 插值表达式 指令

1.【架构师成长之路】学生时代:大学期间应该如何准备(上)

文章目录 导言一、形成自己的学习方法论【知识多】是指专业知识丰富。【变化多】指工作的内容变化多。 二、让自己充满好奇心本章小结说明 导言 成为架构师之路&#xff0c;一共分四个阶段&#xff1a;学生时代、职场新人、工程师、架构师。接下来我们首先介绍学生时代。 大学…

Maxwell - 增量数据同步工具

前言 今天来学习一个新的大数据小工具 Maxwell &#xff0c;它和 Sqoop 很像。Sqoop主要用于在 Hadoop &#xff08;比如 HDFS、Hive、HBase 等&#xff09;和关系型数据库之间进行数据的批量导入和导出&#xff0c;而 Maxwell 则主要用于监控数据库的变化&#xff08;通过监控…