查看: 1715|回复: 2

[有事请教] 请问如何实现某个属性在更改装备时数值变化的颜色相反

[复制链接]
梦石
0
星屑
124
在线时间
21 小时
注册时间
2023-5-15
回帖
4
发表于 2023-10-10 20:52:17 | 显示全部楼层 |阅读模式
悬赏20星屑已解决
一般来说,在修改装备的时候,显示属性值的改变,一般使用绿色表示提升,用红色表示下降。

我在游戏中使用‘负重’来代替‘幸运’这一属性,如果负重过高则会影响回避率,是一种负面属性,所以想让这个属性的提升变为红色,下降变为绿色,想请教各位大佬有没有好的办法,谢谢~~!
Snipaste_2023-10-10_20-51-00.png

最佳答案

查看完整内容

在rmmz_managers.js中可以找到以下代码来控制颜色,需要对它的定义进行改写来加入属性ID参数,同时在调用它的两个地方传入属性ID。 [pre lang="js" line="1800"]ColorManager.paramchangeTextColor = function(change, paramId) { if (paramId === 7) change = -change; // 上一行为修改内容(添加paramId参数),本行为新增内容,表示幸运值(7号属性)为负面属性,增加为红,减少为绿 if (change > 0) { return ...
梦石
2
星屑
8479
在线时间
463 小时
注册时间
2021-12-4
回帖
486

MZ评测员

发表于 2023-10-10 20:52:18 | 显示全部楼层
在rmmz_managers.js中可以找到以下代码来控制颜色,需要对它的定义进行改写来加入属性ID参数,同时在调用它的两个地方传入属性ID。
[pre lang="js" line="1800"]ColorManager.paramchangeTextColor = function(change, paramId) {
    if (paramId === 7) change = -change; // 上一行为修改内容(添加paramId参数),本行为新增内容,表示幸运值(7号属性)为负面属性,增加为红,减少为绿
    if (change > 0) {
        return this.powerUpColor();
    } else if (change < 0) {
        return this.powerDownColor();
    } else {
        return this.normalColor();
    }
};[/pre]
下面两段代码都在rmmz_windows.js文件。
[pre lang="js" line="2570"]Window_EquipStatus.prototype.drawNewParam = function(x, y, paramId) {
    const paramWidth = this.paramWidth();
    const newValue = this._tempActor.param(paramId);
    const diffvalue = newValue - this._actor.param(paramId);
    this.changeTextColor(ColorManager.paramchangeTextColor(diffvalue, paramId)); // 本行为修改内容,添加paramId参数
    this.drawText(newValue, x, y, paramWidth, "right");
};
// 以上为第2570行,以下为第3730行。
Window_ShopStatus.prototype.drawActorParamChange = function(x, y, actor, item1) {
    const width = this.innerWidth - this.itemPadding() - x;
    const paramId = this.paramId();
    const change = this._item.params[paramId] - (item1 ? item1.params[paramId] : 0);
    this.changeTextColor(ColorManager.paramchangeTextColor(change, paramId)); // 本行为修改内容,添加paramId参数
    this.drawText((change > 0 ? "+" : "") + change, x, y, width, "right");
};
[/pre]
回复

使用道具 举报

梦石
0
星屑
124
在线时间
21 小时
注册时间
2023-5-15
回帖
4
 楼主| 发表于 2023-10-11 09:38:37 | 显示全部楼层
本帖最后由 Zyhond 于 2023-10-11 09:39 编辑

修改了代码之后就弄好了,现在就可以实现想要的效果了

谢谢大佬~!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部