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

news/2024/5/18 12:24:45 标签: ui, javascript, 技术美术, 游戏程序, 开发语言

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

  • 法术物品窗口
    • 代码
    • 仿新仙剑效果

法术物品窗口

继续水点内容
现在发出及确认物品窗口显示及操作。

代码

javascript">function Window_BattleItem() {
    this.initialize.apply(this, arguments);
}

Window_BattleItem.prototype = Object.create(Pal_Window_ItemList.prototype);
Window_BattleItem.prototype.constructor = Window_BattleItem;

Window_BattleItem.prototype.initialize = function(x, y, width, height) {
    Pal_Window_ItemList.prototype.initialize.call(this, x, y, width, height);
    this.hide();
};

Window_BattleItem.prototype.includes = function(item) {
    return $gameParty.canUse(item);
};

Window_BattleItem.prototype.show = function() {
    this.selectLast();
    this.showHelpWindow();
    Pal_Window_ItemList.prototype.show.call(this);
};

Window_BattleItem.prototype.hide = function() {
    this.hideHelpWindow();
    Pal_Window_ItemList.prototype.hide.call(this);
};

这里和法术窗口是一样的继承了之前的窗口。

javascript">Pal_Scene_Battle.prototype.createItemWindow = function() {
    this._itemWindow = new Window_BattleItem(39, 169, 561, 213);
    this._itemWindow.setHelpWindow(this._helpWindow);
    this._itemWindow.setHandler('ok',     this.onItemOk.bind(this));
    this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
    this.addChild(this._itemWindow);
};

创建物品战斗窗口。

javascript">Pal_Scene_Battle.prototype.commandItem = function() {
	this._skillBackgroundSprite.visible=true;
	this._skillHelpBackgroundSprite.visible=true;
	this._itemWindow.refresh();
	this._itemWindow.show();
	this._itemWindow.activate();
};

打开物品窗口,并显示背景。

javascript">Pal_Scene_Battle.prototype.onActorCancel = function() {
    this._actorWindow.hide();
	if(this._actorCommandWindow.currentSymbol()==='skill'){
		this._skillBackgroundSprite.visible=true;
		this._skillHelpBackgroundSprite.visible=true;
		this._skillWindow.show();
		this._skillWindow.activate();
	}
	if(this._itemCommandWindow.currentSymbol()==='use'){
		this._skillBackgroundSprite.visible=true;
		this._skillHelpBackgroundSprite.visible=true;
		this._itemWindow.show();
		this._itemWindow.activate();
	}
	
};
Pal_Scene_Battle.prototype.onEnemyCancel = function() {
    this._enemyWindow.hide();
	if(this._actorCommandWindow.currentSymbol()==='attack'){
		this._actorCommandWindow.activate();
	}
	if(this._actorCommandWindow.currentSymbol()==='skill'){
		this._skillBackgroundSprite.visible=true;
		his._skillHelpBackgroundSprite.visible=true;
		this._skillWindow.show();
		this._skillWindow.activate();
	}
	if(this._itemCommandWindow.currentSymbol()==='use'){
		this._skillBackgroundSprite.visible=true;
		this._skillHelpBackgroundSprite.visible=true;
		this._itemWindow.show();
		this._itemWindow.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();
    }
};

这三个方法是在使用物品或使用法术时调用的。
onSelectAction 方法中判断了目标对象的操作,因此在判断前,将法术及物品的战斗窗口均进行隐藏。
onActorCancel onEnemyCancel 角色和敌人选择的取消方法法术及物品使用上之前是switch语句进行判断的,但为了仿仙剑的一致性,因此将处理了这些方法操作,开启对应的背景,但麻烦来了,每个操作的标志默认判断是传入的角色的战斗指令操作,这样就会导致能使用法术的,但物品的就判断不了,因此将switch语句改成多个if判断,这样就能根据需要的内容进行处理了。

javascript">Pal_Scene_Battle.prototype.onItemOk = function() {
	this._skillBackgroundSprite.visible=false;
	this._skillHelpBackgroundSprite.visible=false;
	this._itemCommandWindow.hide();
	this._otherCommandWindow.hide();
    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._skillBackgroundSprite.visible=false;
	this._skillHelpBackgroundSprite.visible=false;
	this._itemCommandWindow.show();
	this._otherCommandWindow.show();
	this.startItemCommandSelection();
    this._itemWindow.hide();
};

物品的使用及取消物品战斗菜单,这里着重说下取消的,里面调用了开始物品命令选择的方法,这是为了能够正常的跳转回物品战斗的指令窗口,和原版游戏的操作保持一致。

仿新仙剑效果

在这里插入图片描述
这样的基本的UI效果和操作的效果就出来了!


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

相关文章

Ubuntu开启麦克风降噪功能

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言一、pulseaudio是什么?二、module-echo-cancel三、声卡四、开启降噪1.内置声卡2.外置声卡3.其它设置 五、配置持久化六、给些建议总结 前言 最近有…

蓝桥杯每日一题(dfs)

3502 不同路径数 1、要注意以每个点为起点都要dfs 2、自己用1-n 1-m存数不知道为什么报错 3、自己写的时候参数写对了 层数,来源的位置,前面累计的数 4、边界:0-k-1实现了k次,到k的时候,直接将res加入set 5、否则…

Error response from daemon Get server gave HTTP response to HTTPS client

使用docker compose拉起docker镜像时,若出现如下报错 Error response from daemon: Get "https://devops.test.cn:5000/v2/": http: server gave HTTP response to HTTPS client表示Docker守护进程无法从指定url获取响应, 可能原因有以下&…

用DevOpsGPT 5分钟开发一个网页小游戏

前言: 今天教大家如何制作一个简易的网页小游戏,步骤很简单,我们只需要用到一个智能开发软件,即可自动帮助我们完成开发。话不多说,接下来,我们直接上教程! ​ 官网:KUAFUAI - AI 驱…

PCL点云处理之三点定圆 (二百三十二)

PCL点云处理之三点定圆 (二百三十二) 一、算法介绍二、算法实现一、算法介绍 二维平面,给定三个点,确定唯一圆的中心和半径参数。 二、算法实现 #include <iostream> #include <cmath>struct Point {

政安晨:【深度学习实践】【使用 TensorFlow 和 Keras 为结构化数据构建和训练神经网络】(四)—— 过拟合和欠拟合

政安晨的个人主页&#xff1a;政安晨 欢迎 &#x1f44d;点赞✍评论⭐收藏 收录专栏: 政安晨的机器学习笔记 希望政安晨的博客能够对您有所裨益&#xff0c;如有不足之处&#xff0c;欢迎在评论区提出指正&#xff01; 通过增加容量或提前停止来提高性能。 在深度学习中&#…

Verilog刷题笔记41

题目&#xff1a;Create 8 D flip-flops with active high asynchronous reset. All DFFs should be triggered by the positive edge of clk. 解题&#xff1a; module top_module (input clk,input areset, // active high asynchronous resetinput [7:0] d,output [7:0]…

2024开年首展,加速科技展台“热辣滚烫”

3月20日&#xff0c;备受瞩目的半导体行业盛会SEMICON China 2024在上海新国际博览中心盛大启幕&#xff0c;展会汇集了来自全球的半导体领域顶尖企业与专业人士。加速科技作为业界领先的半导体测试设备供应商携重磅测试设备及解决方案精彩亮相&#xff0c;展示了最新的半导体测…