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

news2024/9/19 10:39:37

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

  • 战斗状态菜单
    • 原始RMMV 菜单窗口
    • 仿新仙剑代码
    • 仿新仙剑战斗状态菜单

战斗状态菜单

这部分比较简单,由于有主菜单的状态菜单打底所以开发上也容易些。

原始RMMV 菜单窗口

在原版的RMMV中显示的数据主要是人物的HPMPTP、和两个计量条人物姓名,不需要显示的东西可以不进行显示。
在这里插入图片描述
如图显示是很单调的,主菜单的好歹还有个头像,这个就少了一些东西。

仿新仙剑代码


function Window_BattleStatus() {
    this.initialize.apply(this, arguments);
}

Window_BattleStatus.prototype = Object.create(Window_Selectable.prototype);
Window_BattleStatus.prototype.constructor = Window_BattleStatus;

Window_BattleStatus.prototype.initialize = function(x,y) {
    Window_Selectable.prototype.initialize.call(this, x, y, 465, 116);
    this.characterStateFrame=ImageManager.loadMenu('CharacterStateFrame');
    this.refresh();
};
Window_BattleStatus._faceWidth=144;
Window_BattleStatus._faceHeight=112;
//标准内边距
Window_BattleStatus.prototype.standardPadding = function() {
    return 0;//18;
};
Window_BattleStatus.prototype.numVisibleRows = function() {
    return 1;
};
//设置状态菜单的最大列数
Window_BattleStatus.prototype.maxCols = function() {
	return 3;
};

//最大项目数
Window_BattleStatus.prototype.maxItems = function() {
	return $gameParty.size();
};
//间距
Window_BattleStatus.prototype.spacing = function() {
    return 6;
};

//每项高度
Window_BattleStatus.prototype.itemHeight = function() {
	var clientHeight = this.height - this.padding * 2;
	return Math.floor(clientHeight / this.numVisibleRows());
};

Window_BattleStatus.prototype.drawItem = function(index) {
    this.drawItemImage(index);
    this.drawItemStatus(index);
};
//绘制人物背景
Window_BattleStatus.prototype.drawItemBackground = function(index) {
	if (index === this._pendingIndex) {
		var rect = this.itemRect(index);
		//var color = this.pendingColor();
		var color = this.deathColor();
		this.changePaintOpacity(false);
		this.contents.fillRect(rect.x, rect.y, rect.width, rect.height, color);
		this.changePaintOpacity(true);
	}
};
//绘制人物图像
Window_BattleStatus.prototype.drawItemImage = function(index) {
	var actors = $gameParty.members();
	var actor=actors[index];
	var rect = this.itemRect(index);
	this.changePaintOpacity(actor.isBattleMember());
	this.drawActorFace(actor, rect.x + 2, rect.y + 1, rect.width, rect.height,index);
	this.changePaintOpacity(true);
};

//绘制演员头像
Window_BattleStatus.prototype.drawActorFace = function(actor, x, y, width, height,index) {
    this.drawFace(actor.faceName(), actor.faceIndex(), x, y, width, height,index);
};

//绘制头像
Window_BattleStatus.prototype.drawFace = function(faceName, faceIndex, x, y, width, height,index) {
	var actors=$gameParty.members();
	var wx=0;
	switch(actors.length){
		case 1:
			wx=154*2;
			break;
		case 2:
			wx=154;
			break;
		default:
			break;
	}
    width = width || Window_BattleStatus._faceWidth;
    height = height || Window_BattleStatus._faceHeight;
    var bitmap = ImageManager.loadFace(faceName);
    var pw = Window_BattleStatus._faceWidth;
    var ph = Window_BattleStatus._faceHeight;
    var sw = Math.min(width, pw);
    var sh = Math.min(height, ph);
    var sx = faceIndex % 6 * pw + (pw - sw) / 2;
    var sy = Math.floor(faceIndex / 6) * ph + (ph - sh) / 2;
	
	
   if(!bitmap.isReady()){
	   setTimeout(()=>{
			this.contents.blt(bitmap, sx, sy, sw, sh, x+wx, y);
			this.drawItemStatus(index);
	   },0.25);
   }else{
	    this.contents.blt(bitmap, sx, sy, sw, sh, x+wx, y);
   }
};

//绘制人物状态
Window_BattleStatus.prototype.drawItemStatus = function(index) {
	var actor = $gameParty.members()[index];
	var rect = this.itemRect(index);
	this.drawActorSimpleStatus(actor, rect.x,  rect.y, rect.width,rect.height);
};

//绘制演员简单状态
Window_BattleStatus.prototype.drawActorSimpleStatus = function(actor, x, y, width,height) {
    this.drawActorIcons(actor, x+73, y+36,width,height);// 人物状态图标
    this.drawActorHp(actor, x, y, width);
	this.drawActorMp(actor, x, y, width);
};

//绘制演员图标,作为参考及绘制四种状态
Window_BattleStatus.prototype.drawActorIcons = function(actor, x, y, width) {
    width = width || 144;
	var actorStates=actor.states(); //获取人物状态
	var stateIcons=[];
	for (var i = 0; i < actorStates.length; i++) {
		if (actorStates[i].id>13&&actorStates[i].id<18) {
			stateIcons.push(actorStates[i].iconIndex);
		}
	}
    for (var i = 0; i < stateIcons.length&&i<2; i++) {
        this.drawIcon(stateIcons[i]-12, x + 24 * i+(i*5), y);
    }
};
//绘制状态图标
Window_BattleStatus.prototype.drawIcon = function(iconIndex, x, y) {
	var actors=$gameParty.members();
	var wx=0;
	switch(actors.length){
		case 1:
			wx=154*2;
			break;
		case 2:
			wx=154;
			break;
		default:
			break;
	}
	x=x+wx;
    var bitmap = ImageManager.loadSystem('CharacterStatus');
    var pw = 24;
    var sx = iconIndex % 5 * pw;
    var sy = 0;
	if(!bitmap.isReady()){
		   //console.log(bitmap.isReady())
		   setTimeout(()=>{this.contents.blt(bitmap, sx, sy, pw, 26, x, y);},0.25);
	}else{
		    this.contents.blt(bitmap, sx, sy, pw, 26, x, y);
	}
};
//绘制演员HP
Window_BattleStatus.prototype.drawActorHp = function(actor, x, y, width) {
    width = width || 144;
	var color1 = this.textColor(10);
    var color2 = this.textColor(15);
    this.drawCurrentAndMax(actor.hp, actor.mhp, x-2, y+56, width,color1, color2);
};
//绘制演员MP
Window_BattleStatus.prototype.drawActorMp = function(actor, x, y, width) {
    width = width || 144;
    var color1 = this.textColor(9);
    var color2 = this.textColor(15);
    this.drawCurrentAndMax(actor.mp, actor.mmp, x-10, y+74, width,color1, color2);
};

//绘制现在和最大值
Window_BattleStatus.prototype.drawCurrentAndMax = function(current, max, x, y,
                                                   width, color1, color2) {
   var actors=$gameParty.members();
   var wx=0;
   switch(actors.length){
	case 1:
		wx=154*2;
		break;
	case 2:
		wx=154;
		break;
	default:
		break;
   }
   x=x+wx;
	this.contents.fontSize=14;//设置字体大小
    var labelWidth = this.textWidth('HP');//28
    var valueWidth = this.textWidth('0000');//56
    var slashWidth = this.textWidth('/');//14
    var x1 = x + width - valueWidth;
    var x2 = x1 - slashWidth;
    var x3 = x2 - valueWidth;
    if (x3 >= x + labelWidth) {
        this.changeTextColor(color1);
		this.contents.outlineColor=color1;
		this.contents.outlineWidth = 0;
        this.drawText(current, x3, y, valueWidth, 'right');
        this.changeTextColor(color2);
		this.contents.outlineColor=color2;
		this.contents.outlineWidth = 0;
        this.drawText('/', x2, y, slashWidth, 'center');
		this.changeTextColor(color1);
		this.contents.outlineColor=color1;//轮廓颜色
		this.contents.outlineWidth = 0;//轮廓宽度
        this.drawText(max, x1, y, valueWidth, 'left');
    } else {
		this.contents.outlineColor=color1;//轮廓颜色
		this.contents.outlineWidth = 0;//轮廓宽度
        this.changeTextColor(color1);
        this.drawText(current, x1, y, valueWidth, 'left');
    }
};

//绘制文本
Window_BattleStatus.prototype.drawText = function(text, x, y, maxWidth, align) {
    this.contents.drawText(text, x, y, maxWidth, this.lineHeight(), align);
};
//等待索引
Window_BattleStatus.prototype.pendingIndex = function() {
	return this._pendingIndex;
};
//刷新光标
Window_BattleStatus.prototype._refreshCursor = function() {
	var pad = this._padding;
	var x = this._cursorRect.x;
	var y = this._cursorRect.y;
	var w = this._cursorRect.width;
	var h = this._cursorRect.height;
    var bitmap = new Bitmap(w, h);
    this._windowCursorSprite.bitmap = bitmap;
    this._windowCursorSprite.setFrame(0, 0, w, h);
	var actors=$gameParty.members();
	var wx=0;
	switch(actors.length){
		case 1:
			wx=154*2;
			break;
		case 2:
			wx=154;
			break;
		default:
			break;
	}
    this._windowCursorSprite.move(wx+x, y);
    if (w > 0 && h > 0&&this.characterStateFrame) {
		var csf=this.characterStateFrame;
		this._windowCursorSprite.bitmap.blt(csf,0,0,164,96,0-3,0+20,164,96);
    }
};
//更新光标
Window_BattleStatus.prototype._updateCursor = function() {
	this._windowCursorSprite.bitmap.clear();
	var blinkCount = this._animationCount % 50;
	var characterStateSpriteY=0;
    if (this._windowCursorSprite.visible) {
		switch(Math.floor(blinkCount/10)){
			case 0:
				characterStateSpriteY=0;
			break;
			case 1:
				characterStateSpriteY=96;
			break;
			case 2:
				characterStateSpriteY=192;
			break;
			case 3:
				characterStateSpriteY=288;
			break;
			case 4:
				characterStateSpriteY=384;
			break;
			default:
				//characterStateSpriteY=4*96;
			break;
		}
    }
	this._windowCursorSprite.bitmap.blt(this.characterStateFrame,0,characterStateSpriteY,164,96,0-3,0+20,164,96);
	this._windowCursorSprite.visible = this.isOpen();
};

Window_BattleStatus.prototype.update = function() {
    Window_Selectable.prototype.update.call(this);
	this._animationCount++;
};

这里只对其中部分代码做出解释,大部分代码在之前都说过的。
initialize 方法中,调用的父类传入的参数width和主菜单的不同,这是为什么,这是因为主菜单时做的是4角色同框的,而这里是3个角色同框的,后期应该会保持一致。
maxCols 方法中的参数也是这个作用。

	switch(actors.length){
		case 1:wx=154*2;break;
		case 2:wx=154;break;
		default:break;
	}

这部分代码也是这个作用,重新计算需要绘制图像的位置
_updateCursor 这个更新光标的方法中判断的条件发生了变化,原来是按照是否激活来判断,现在按照是否隐藏来判断,这是因为,默认窗口是取消激活的,而激活后导致的问题就是在使用其他菜单时会操作到这个菜单,因此需要取消激活,但是光标的更新就出现了问题,因此需要更换判断条件。
update 正常来说更新的方法是不用显示的写出来的,因为会自动执行,但里面的代码更新动画的变量是在窗口激活时才进行计数的,因此需要子类显示调用父类后重新进行动画更新计时的增加,不然就不能正常显示。

仿新仙剑战斗状态菜单

如图:
在这里插入图片描述
做出来的样子就是这样的,当然了,现在是暂时没有去掉背景的,后期全部完善战斗场景的窗口和功能后再去掉背景。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1532991.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

鲁棒的基于表面势的GaN HEMT集成电路紧凑模型

来源&#xff1a;Robust Surface-Potential-Based Compact Model forGaN HEMT IC Design&#xff08;TED 13年&#xff09; 摘要 我们提出了一种精确且稳健的基于表面势的紧凑模型&#xff0c;用于模拟采用氮化镓高电子迁移率晶体管&#xff08;GaN HEMT&#xff09;设计的电…

JAVA实战开源项目:大学计算机课程管理平台(Vue+SpringBoot)

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块2.1 实验课程档案模块2.2 实验资源模块2.3 学生实验模块 三、系统设计3.1 用例设计3.2 数据库设计3.2.1 实验课程档案表3.2.2 实验资源表3.2.3 学生实验表 四、系统展示五、核心代码5.1 一键生成实验5.2 提交实验5.3 批阅实…

【算法】雪花算法生成分布式 ID

SueWakeup 个人中心&#xff1a;SueWakeup 系列专栏&#xff1a;学习Java框架 个性签名&#xff1a;人生乏味啊&#xff0c;我欲令之光怪陆离 本文封面由 凯楠&#x1f4f7; 友情赞助播出! 目录 1. 什么是分布式 ID 2. 分布式 ID 基本要求 3. 数据库主键自增 4. UUID 5. S…

PyTorch 深度学习(GPT 重译)(四)

第二部分&#xff1a;从现实世界的图像中学习&#xff1a;肺癌的早期检测 第 2 部分的结构与第 1 部分不同&#xff1b;它几乎是一本书中的一本书。我们将以几章的篇幅深入探讨一个单一用例&#xff0c;从第 1 部分学到的基本构建模块开始&#xff0c;构建一个比我们迄今为止看…

【Python + Django】ORM 数据库操作

前言&#xff1a; 虽然我们知道了用MySQL数据库 pymysql可以进行数据库的连接&#xff0c; 但这样的方式太繁琐了。 本文介绍一下Django为我们提供的更简单便捷的数据库连接方式&#xff1a;ORM框架。 ORM为我们翻译代码&#xff0c;使得我们的代码更加简洁易懂。 1 连接…

28-5 文件上传漏洞 - 图片马

一、文件内容检测 解析漏洞定义 控制文件是否被当做后端脚本处理 二、图片马绕过 图片马;在图片中包含一句话木马。利用解析漏洞如.htaccess 或文件包含漏洞,对图片马进行解析,执行其中的恶意代码。优势在于可以绕过多种防护机制。 三、图片马制作方法: # 一句话马示例…

Maven Deploy测试

文章目录 Maven环境deployreleaseRepo Manager演示 RefFAQ Maven 环境 jdk8maven v3.9.5 deploy mvn install将jar存到localRepository&#xff0c;mvn deploy把jar推送到远程仓库&#xff0c;然后可以像central库那样下载依赖。 release 基于git执行项目发版流程&#x…

【机器学习智能硬件开发全解】(六)—— 政安晨:通过ARM-Linux掌握基本技能【认知准备:体系结构与汇编指令】

ARM-Linux体系是指基于ARM架构的Linux操作系统体系&#xff0c;其它常见的体系还有x86-Linux体系等。ARM架构是一种常用于移动设备和嵌入式系统的处理器架构&#xff0c;如手机、平板电脑、智能手表等都广泛使用ARM处理器。 ARM-Linux体系基于Linux开源操作系统&#xff0c;并…

Python将字符串转换为datetime

有这样一些字符串&#xff1a; 1710903685 20240320110125 2024-03-20 11:01:25 要转换成Python的datetime 代码如下&#xff1a; import functools import re from datetime import datetime, timedelta from typing import Union# pip install python-dateutil from date…

51单片机学习笔记8 中断系统及定时器

51单片机学习笔记8 中断系统及定时器 一、中断的概念二、51单片机的中断1. 51单片机的中断源2. 中断的优先级3. 中断结构4. 外部中断解读5. 定时器中断6. 串口中断 三、中断相关寄存器1. IE 中断允许寄存器2. TCON 中断请求标志3. IP 中断优先级 四、中断号五、代码实现按键 &a…

如何实现跨标签页通讯

什么是跨标签页通讯 同一浏览器&#xff0c;可以打开多个标签页&#xff0c;跨标签页通讯就是&#xff0c;一个标签页能够发消息给另一标签页。 有哪些实现方案 localStorage &#xff08;window.onstorage事件监听&#xff09;BroadcastChannel&#xff08;广播&#xff09…

Redis如何设置键的生存时间或过期时间

键的生存时间或过期时间 概述。 通过EXPIRE命令或者PEXIPIRE命令&#xff0c;客户端可以以秒或者毫秒精度为数据库中的某个键设置生存时间(Time To Live,TTL)&#xff0c;在经过指定的秒数或者毫秒数之后&#xff0c;服务器就会自动删除生存时间为0的键: 127.0.0.1:6379>…

Python零基础---爬虫技术相关

python 爬虫技术&#xff0c;关于数据相关的拆解&#xff1a; 1.对页面结构的拆解 2.数据包的分析&#xff08;是否加密了参数&#xff09;&#xff08;Md5 aes&#xff09;难易程度&#xff0c;价格 3.对接客户(433,334) # 数据库 CSV 4.结单&#xff08;发一部分数据&a…

酷开系统满足你的需求,加入酷开会员开启娱乐之旅

酷开科技深知家庭娱乐在我们生活中的重要性&#xff0c;因此&#xff0c;酷开科技不断努力为我们带来更好的内容和服务&#xff0c;在这里&#xff0c;我们能够享受到家庭娱乐的乐趣和便利&#xff0c;感受到酷开科技带来的温暖。电影迷、游戏迷还是音乐爱好者&#xff0c;酷开…

1236 - 二分查找

代码 #include<bits/stdc.h> using namespace std; int a[1100000]; int main() {int n,x,l,r,p,mid,i;cin>>n;for(i1;i<n;i)cin>>a[i];cin>>x;l1;rn;p-1;while(l<r){mid(rl)/2;if(a[mid]x){pmid;break;}else if(x<a[mid]) rmid-1;else if(x…

k8s为什么删除了pod但是还是没删除掉的问题,deployment在影响

deployment 影响pod删除 一、问题所在二、解决问题 一、问题所在 执行&#xff1a;kubectl get pods --all-namespaces&#xff0c;获取dashboard相关的pod kubectl get pods --all-namespaces | grep dashboardkubectl delete pod dashboard-metrics-scraper-546d6779cb-4x6…

备战秋招(coding篇)

其中coding题目来源于师兄面试经验 1、链表的结构体反转链表 本质上就是一个构造函数 struct ListNode{int val_;ListNode* next_;ListNode() : val_(0), next_(NULL) {}ListNode(int x) : val_(x), next_(NULL) {}ListNode(int x, ListNode* next) : val_(x), next_(next) …

【Spring Cloud】微服务通信概述

SueWakeup 个人主页&#xff1a;SueWakeup 系列专栏&#xff1a;学习技术栈 个性签名&#xff1a;人生乏味啊&#xff0c;我欲令之光怪陆离 本文封面由 凯楠&#x1f4f7; 友情赞助播出 目录 前言 1. Dubbo&#xff08;Spring Cloud Alibaba&#xff09;和 Spring Cloud 的适…

使用ollama + webui 运行任意大模型

安装ollama https://hub.docker.com/r/ollama/ollama docker run -d -v ~/Documents/work/softs/docker/ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama验证安装 # 进入容器docker exec -it ollama bash # 运行大模型 ollama run llama2 # 发送请求&…

【python + Django】Django模板语法 + 请求和响应

前言&#xff1a; 现在现在&#xff0c;我们要开始将变量的值展现在页面上面啦&#xff01; 要是只会显示静态页面&#xff0c;我们的页面也太难看和死板了&#xff0c; 并且数据库的数据也没法展现在页面上。 但是呢&#xff0c;模板语法学习之后就可以啦&#xff01;&…