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

news/2024/5/18 14:45:36 标签: ui, javascript, 开发语言, 游戏程序, 游戏

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

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

战斗指令菜单

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

原仙剑战斗指令图

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

RMMV战斗指令对应代码

战斗时,分配键盘上Up键对应攻击,Down键对应其他,Left键对应法术,Right键对应合击。

战斗指令菜单

javascript">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);
	}
};

这里进行了简化,四个按键操作原来需要获取指令序号及指令的数量后计算下一个操作的指令,现在全部简化为,判断是否按下对应按键,就执行对应的指令。

代码

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

效果

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


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

相关文章

【Linux取经路】文件系统之重定向的实现原理

文章目录 一、再来理解重定向1.1 输出重定向效果演示1.2 重定向的原理1.3 dup21.4 输入重定向效果演示1.5 输入重定向代码实现 二、再来理解标准输出和标准错误2.1 同时对标准输出和标准错误进行重定向2.2 将标准输出和标准错误重定向到同一个文件 三、再看一切皆文件四、结语 …

机器视觉缺陷检测:工业自动化的重要推动力

机器视觉缺陷检测确实是工业自动化的重要推动力。随着工业生产的快速发展,对产品质量的要求也越来越高,传统的人工检测方式已经无法满足高效、精确的检测需求。而机器视觉技术的出现,为工业自动化带来了革命性的变革。 首先,机器…

Python 进阶语法:正则表达式

正则表达式是一个特殊的字符序列,它能帮助你方便的检查一个字符串是否与某种模式匹配。 在 Python 中,使用 re 模块来处理正则表达式。re 模块提供了一组函数,允许你在字符串中进行模式匹配、搜索和替换操作。re 模块使 Python 语言拥有完整…

基于SSM的在线教学质量评价系统(有报告)。Javaee项目。ssm项目。

演示视频: 基于SSM的在线教学质量评价系统(有报告)。Javaee项目。ssm项目。 项目介绍: 采用M(model)V(view)C(controller)三层体系结构,通过Spri…

Redis在Linux服务器中详细安装与配置步骤

一、安装redis 下载reidis:附redis官网地址:https://redis.io/download/ ,建议下载稳定版 1、将redis linux版压缩包放置于一个路径下,通过命令tar -zxvf redis-5.0.7.tar.gz 解压 2、安装gcc编译环境,如果已安装过了…

【开发战斗系统很难?这几个重要的技术点千万不能忽视!】

作为网游中最重要的MMO类游戏的前身,ARPG游戏是一种非常经典且流行的游戏类型,其诞生的经典之作如:《魂系》、《暗黑破坏神系列》、《塞尔达传说系列》等,大家也是耳熟能详。 可以说ARPG游戏无论从体量还是技术含量都是游戏开发领…

二叉搜索树——迭代实现

———————————————————— 普通的树形结构中数据是杂乱无章的,实际意义不大,要想更好的管理数据,需要让数据有序,二叉搜索树又称二叉排序树,是一种特殊的树形结构。 规定一般的二叉搜索树的左节点小于…

2024-02-19(Flume,DataX)

1.flume中拦截器的作用:个人认为就是修改或者删除事件中的信息(处理一下事件)。 2.一些拦截器 Host Interceptor,Timestamp Interceptor,Static Interceptor,UUID Interceptor,Search and Rep…