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

2024-02-20 15:28

本文主要是介绍【RPG Maker MV 仿新仙剑 战斗场景UI (二)】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

  • 战斗指令菜单
    • 原仙剑战斗指令图
    • RMMV战斗指令对应代码
      • 战斗指令菜单
      • 代码
      • 效果

战斗指令菜单

原仙剑战斗指令菜单是使用方向键控制,同时按照使用情况正好对应四个指令和四个方向,同时没有选中的菜单用黑色透明图片覆盖,达到未选中的效果,红色图片表示不能进行选中(即不能使用)。

原仙剑战斗指令图

原仙剑战斗指令图
通过该图可以清楚的看到未选中及选中、不能选中的情况;同时可以看到其他指令菜单的位置也算是做一下绝对的定位。

RMMV战斗指令对应代码

战斗时,分配键盘上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方法分别是进行更新和刷新指令图标的,这样后期若是需要人物不能操作时就可以实现效果。

效果

在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
基础战斗菜单就已完成,之后将制作其他指令的中的二级和三级菜单。

这篇关于【RPG Maker MV 仿新仙剑 战斗场景UI (二)】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/728667

相关文章

Python主动抛出异常的各种用法和场景分析

《Python主动抛出异常的各种用法和场景分析》在Python中,我们不仅可以捕获和处理异常,还可以主动抛出异常,也就是以类的方式自定义错误的类型和提示信息,这在编程中非常有用,下面我将详细解释主动抛... 目录一、为什么要主动抛出异常?二、基本语法:raise关键字基本示例三、raise的多种用法1. 抛

Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析

《Spring组件实例化扩展点之InstantiationAwareBeanPostProcessor使用场景解析》InstantiationAwareBeanPostProcessor是Spring... 目录一、什么是InstantiationAwareBeanPostProcessor?二、核心方法解

Java 枚举的基本使用方法及实际使用场景

《Java枚举的基本使用方法及实际使用场景》枚举是Java中一种特殊的类,用于定义一组固定的常量,枚举类型提供了更好的类型安全性和可读性,适用于需要定义一组有限且固定的值的场景,本文给大家介绍Jav... 目录一、什么是枚举?二、枚举的基本使用方法定义枚举三、实际使用场景代替常量状态机四、更多用法1.实现接

java -jar命令运行 jar包时运行外部依赖jar包的场景分析

《java-jar命令运行jar包时运行外部依赖jar包的场景分析》:本文主要介绍java-jar命令运行jar包时运行外部依赖jar包的场景分析,本文给大家介绍的非常详细,对大家的学习或工作... 目录Java -jar命令运行 jar包时如何运行外部依赖jar包场景:解决:方法一、启动参数添加: -Xb

C/C++ chrono简单使用场景示例详解

《C/C++chrono简单使用场景示例详解》:本文主要介绍C/C++chrono简单使用场景示例详解,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友... 目录chrono使用场景举例1 输出格式化字符串chrono使用场景China编程举例1 输出格式化字符串示

VS配置好Qt环境之后但无法打开ui界面的问题解决

《VS配置好Qt环境之后但无法打开ui界面的问题解决》本文主要介绍了VS配置好Qt环境之后但无法打开ui界面的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要... 目UKeLvb录找到Qt安装目录中designer.UKeLvBexe的路径找到vs中的解决方案资源

Java集成Onlyoffice的示例代码及场景分析

《Java集成Onlyoffice的示例代码及场景分析》:本文主要介绍Java集成Onlyoffice的示例代码及场景分析,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要... 需求场景:实现文档的在线编辑,团队协作总结:两个接口 + 前端页面 + 配置项接口1:一个接口,将o

Python Flask 库及应用场景

《PythonFlask库及应用场景》Flask是Python生态中​轻量级且高度灵活的Web开发框架,基于WerkzeugWSGI工具库和Jinja2模板引擎构建,下面给大家介绍PythonFl... 目录一、Flask 库简介二、核心组件与架构三、常用函数与核心操作 ​1. 基础应用搭建​2. 路由与参

IDEA实现回退提交的git代码(四种常见场景)

《IDEA实现回退提交的git代码(四种常见场景)》:本文主要介绍IDEA实现回退提交的git代码(四种常见场景),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.已提交commit,还未push到远端(Undo Commit)2.已提交commit并push到

QT6中绘制UI的两种方法详解与示例代码

《QT6中绘制UI的两种方法详解与示例代码》Qt6提供了两种主要的UI绘制技术:​​QML(QtMeta-ObjectLanguage)​​和​​C++Widgets​​,这两种技术各有优势,适用于不... 目录一、QML 技术详解1.1 QML 简介1.2 QML 的核心概念1.3 QML 示例:简单按钮