【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

相关文章

MySQL常用字符串函数示例和场景介绍

《MySQL常用字符串函数示例和场景介绍》MySQL提供了丰富的字符串函数帮助我们高效地对字符串进行处理、转换和分析,本文我将全面且深入地介绍MySQL常用的字符串函数,并结合具体示例和场景,帮你熟练... 目录一、字符串函数概述1.1 字符串函数的作用1.2 字符串函数分类二、字符串长度与统计函数2.1

Java Stream流之GroupBy的用法及应用场景

《JavaStream流之GroupBy的用法及应用场景》本教程将详细介绍如何在Java中使用Stream流的groupby方法,包括基本用法和一些常见的实际应用场景,感兴趣的朋友一起看看吧... 目录Java Stream流之GroupBy的用法1. 前言2. 基础概念什么是 GroupBy?Stream

java如何实现高并发场景下三级缓存的数据一致性

《java如何实现高并发场景下三级缓存的数据一致性》这篇文章主要为大家详细介绍了java如何实现高并发场景下三级缓存的数据一致性,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 下面代码是一个使用Java和Redisson实现的三级缓存服务,主要功能包括:1.缓存结构:本地缓存:使

C++中detach的作用、使用场景及注意事项

《C++中detach的作用、使用场景及注意事项》关于C++中的detach,它主要涉及多线程编程中的线程管理,理解detach的作用、使用场景以及注意事项,对于写出高效、安全的多线程程序至关重要,下... 目录一、什么是join()?它的作用是什么?类比一下:二、join()的作用总结三、join()怎么

在MySQL中实现冷热数据分离的方法及使用场景底层原理解析

《在MySQL中实现冷热数据分离的方法及使用场景底层原理解析》MySQL冷热数据分离通过分表/分区策略、数据归档和索引优化,将频繁访问的热数据与冷数据分开存储,提升查询效率并降低存储成本,适用于高并发... 目录实现冷热数据分离1. 分表策略2. 使用分区表3. 数据归档与迁移在mysql中实现冷热数据分

WinForm跨线程访问UI及UI卡死的解决方案

《WinForm跨线程访问UI及UI卡死的解决方案》在WinForm开发过程中,跨线程访问UI控件和界面卡死是常见的技术难题,由于Windows窗体应用程序的UI控件默认只能在主线程(UI线程)上操作... 目录前言正文案例1:直接线程操作(无UI访问)案例2:BeginInvoke访问UI(错误用法)案例

nginx -t、nginx -s stop 和 nginx -s reload 命令的详细解析(结合应用场景)

《nginx-t、nginx-sstop和nginx-sreload命令的详细解析(结合应用场景)》本文解析Nginx的-t、-sstop、-sreload命令,分别用于配置语法检... 以下是关于 nginx -t、nginx -s stop 和 nginx -s reload 命令的详细解析,结合实际应

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

MyBatis-Plus 中 nested() 与 and() 方法详解(最佳实践场景)

《MyBatis-Plus中nested()与and()方法详解(最佳实践场景)》在MyBatis-Plus的条件构造器中,nested()和and()都是用于构建复杂查询条件的关键方法,但... 目录MyBATis-Plus 中nested()与and()方法详解一、核心区别对比二、方法详解1.and()

ModelMapper基本使用和常见场景示例详解

《ModelMapper基本使用和常见场景示例详解》ModelMapper是Java对象映射库,支持自动映射、自定义规则、集合转换及高级配置(如匹配策略、转换器),可集成SpringBoot,减少样板... 目录1. 添加依赖2. 基本用法示例:简单对象映射3. 自定义映射规则4. 集合映射5. 高级配置匹