Project1
标题:
关于能力值用槽表示的问题
[打印本页]
作者:
反斗奇彬
时间:
2010-11-2 20:57
标题:
关于能力值用槽表示的问题
本帖最后由 反斗奇彬 于 2010-11-2 21:01 编辑
想把角色的能力值全部用槽来表示,而是是美化的那种,用了天空传说的范例里面的一个脚本,但是除了血槽和魔法槽以外,其他攻击力、防御力的槽表示不出来,脚本在下面,请各位帮忙看看是哪里出现问题(天空传说游戏范例中也是显示不出来),
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
# 游戏中全部窗口的超级类。
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# ● 常量
#--------------------------------------------------------------------------
WLH = 24 # 窗口行高(Window Line Height)
#--------------------------------------------------------------------------
# ● 初始化对像
# x : 窗口 X 座标
# y : 窗口 Y 座标
# width : 窗口宽度
# height : 窗口高度
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super()
self.windowskin = Cache.system("Window")
self.x = x
self.y = y
self.width = width
self.height = height
self.z = 100
self.back_opacity = 200
self.openness = 255
create_contents
@opening = false
@closing = false
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
self.contents.dispose
super
end
#--------------------------------------------------------------------------
# ● 生成窗口内容
#--------------------------------------------------------------------------
def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
if @opening
self.openness += 48
@opening = false if self.openness == 255
elsif @closing
self.openness -= 48
@closing = false if self.openness == 0
end
end
#--------------------------------------------------------------------------
# ● 打开窗口
#--------------------------------------------------------------------------
def open
@opening = true if self.openness < 255
@closing = false
end
#--------------------------------------------------------------------------
# ● 关闭窗口
#--------------------------------------------------------------------------
def close
@closing = true if self.openness > 0
@opening = false
end
#--------------------------------------------------------------------------
# ● 获取文字颜色
# n : 文字颜色色号(0-31)
#--------------------------------------------------------------------------
def text_color(n)
x = 64 + (n % 8) * 8
y = 96 + (n / 8) * 8
return windowskin.get_pixel(x, y)
end
#--------------------------------------------------------------------------
# ● 获取一般文字颜色
#--------------------------------------------------------------------------
def normal_color
return text_color(0)
end
#--------------------------------------------------------------------------
# ● 获取系统文字颜色
#--------------------------------------------------------------------------
def system_color
return text_color(16)
end
#--------------------------------------------------------------------------
# ● 获取危机文字颜色
#--------------------------------------------------------------------------
def crisis_color
return text_color(17)
end
#--------------------------------------------------------------------------
# ● 获取战斗不能文字颜色
#--------------------------------------------------------------------------
def knockout_color
return text_color(18)
end
#--------------------------------------------------------------------------
# ● 获取变量条背景颜色
#--------------------------------------------------------------------------
def gauge_back_color
return text_color(19)
end
#--------------------------------------------------------------------------
# ● 获取体力值槽颜色1
#--------------------------------------------------------------------------
def hp_gauge_color1
return text_color(20)
end
#--------------------------------------------------------------------------
# ● 获取体力值槽颜色2
#--------------------------------------------------------------------------
def hp_gauge_color2
return text_color(21)
end
#--------------------------------------------------------------------------
# ● 获取魔力值槽颜色1
#--------------------------------------------------------------------------
def mp_gauge_color1
return text_color(22)
end
#--------------------------------------------------------------------------
# ● 获取魔力值槽颜色2
#--------------------------------------------------------------------------
def mp_gauge_color2
return text_color(23)
end
#--------------------------------------------------------------------------
# ● 获取装备画面能力值上升颜色
#--------------------------------------------------------------------------
def power_up_color
return text_color(24)
end
#--------------------------------------------------------------------------
# ● 获取装备画面能力值下降颜色
#--------------------------------------------------------------------------
def power_down_color
return text_color(25)
end
#--------------------------------------------------------------------------
# ☆ 能力值槽颜色1之取得
#--------------------------------------------------------------------------
def parameter_gauge_color1
return text_color(11)
end
#--------------------------------------------------------------------------
# ☆ 能力值槽颜色2之取得
#--------------------------------------------------------------------------
def parameter_gauge_color2
return text_color(24)
end
#--------------------------------------------------------------------------
# ☆ EXP值槽颜色1之取得
#--------------------------------------------------------------------------
def exp_gauge_color1
return text_color(30)
end
#--------------------------------------------------------------------------
# ☆ EXP值槽颜色2之取得
#--------------------------------------------------------------------------
def exp_gauge_color2
return text_color(31)
end
#--------------------------------------------------------------------------
# ● 会制图标
# icon_index : 图标号
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# enabled : 有效化标志,为 false 时则图标半透明化。
#--------------------------------------------------------------------------
def draw_icon(icon_index, x, y, enabled = true)
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
end
#--------------------------------------------------------------------------
# ● 绘制头像
# face_name : 头像文件名
# face_index : 头像号码
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# size : 显示大小
#--------------------------------------------------------------------------
def draw_face(face_name, face_index, x, y, size = 96)
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = face_index % 4 * 96 + (96 - size) / 2
rect.y = face_index / 4 * 96 + (96 - size) / 2
rect.width = size
rect.height = size
self.contents.blt(x, y, bitmap, rect)
bitmap.dispose
end
#--------------------------------------------------------------------------
# ● 绘制行走图
# character_name : 行走图文件名
# character_index : 行走图号码
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_character(character_name, character_index, x, y)
return if character_name == nil
bitmap = Cache.character(character_name)
sign = character_name[/^[\!\$]./]
if sign != nil and sign.include?('$')
cw = bitmap.width / 3
ch = bitmap.height / 4
else
cw = bitmap.width / 12
ch = bitmap.height / 8
end
n = character_index
src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ● 获取体力文字颜色
# actor : 角色
#--------------------------------------------------------------------------
def hp_color(actor)
return knockout_color if actor.hp == 0
return crisis_color if actor.hp < actor.maxhp / 4
return normal_color
end
#--------------------------------------------------------------------------
# ● 获取魔力文字颜色
# actor : 角色
#--------------------------------------------------------------------------
def mp_color(actor)
return crisis_color if actor.mp < actor.maxmp / 4
return normal_color
end
#--------------------------------------------------------------------------
# ● 绘制角色行走图
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_graphic(actor, x, y)
draw_character(actor.character_name, actor.character_index, x, y)
end
#--------------------------------------------------------------------------
# ● 绘制角色头像
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# size : 绘制大小
#--------------------------------------------------------------------------
def draw_actor_face(actor, x, y, size = 96)
draw_face(actor.face_name, actor.face_index, x, y, size)
end
#--------------------------------------------------------------------------
# ● 绘制角色名称
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_name(actor, x, y)
self.contents.font.color = hp_color(actor)
self.contents.draw_text(x, y, 108, WLH, actor.name)
end
#--------------------------------------------------------------------------
# ● 绘制角色职业
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_class(actor, x, y)
self.contents.font.color = normal_color
self.contents.draw_text(x, y, 108, WLH, actor.class.name)
end
#--------------------------------------------------------------------------
# ● 绘制角色等级
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_actor_level(actor, x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 32, WLH, Vocab::level_a)
self.contents.font.color = normal_color
self.contents.draw_text(x + 32, y, 24, WLH, actor.level, 2)
end
#--------------------------------------------------------------------------
# ● 绘制角色状态
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_state(actor, x, y, width = 96)
count = 0
for state in actor.states
draw_icon(state.icon_index, x + 24 * count, y)
count += 1
break if (24 * count > width - 24)
end
end
#--------------------------------------------------------------------------
# ● 绘制角色体力
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_hp(actor, x, y, width = 120)
draw_actor_hp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, WLH, Vocab::hp_a)
self.contents.font.color = hp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
if width < 120
self.contents.draw_text(xr - 44, y, 44, WLH, actor.hp, 2)
else
self.contents.draw_text(xr - 90, y, 44, WLH, actor.hp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 44, y, 11, WLH, "/ ", 2)
self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxhp, 2)
end
end
#--------------------------------------------------------------------------
# ● 绘制角色体力值槽
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_hp_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
gw = width * actor.hp / actor.maxhp
gc1 = hp_gauge_color1
gc2 = hp_gauge_color2
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ● 绘制角色魔力
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_mp(actor, x, y, width = 120)
draw_actor_mp_gauge(actor, x, y, width)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 30, WLH, Vocab::mp_a)
self.contents.font.color = mp_color(actor)
last_font_size = self.contents.font.size
xr = x + width
if width < 120
self.contents.draw_text(xr - 44, y, 44, WLH, actor.mp, 2)
else
self.contents.draw_text(xr - 99, y, 44, WLH, actor.mp, 2)
self.contents.font.color = normal_color
self.contents.draw_text(xr - 55, y, 11, WLH, "/", 2)
self.contents.draw_text(xr - 44, y, 44, WLH, actor.maxmp, 2)
end
end
#--------------------------------------------------------------------------
# ● 绘制角色魔力值槽
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_mp_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
gw = width * actor.mp / [actor.maxmp, 1].max
gc1 = mp_gauge_color1
gc2 = mp_gauge_color2
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ 值槽底板描绘
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_gauge_base(x, y, width = 120)
bitmap = Cache.system("gauge")
margin = 3
y += WLH - 8 - margin
dest_rect = Rect.new(x, y, width, bitmap.height)
src_rect = Rect.new(margin, 0, bitmap.width - 16, bitmap.height)
self.contents.stretch_blt(dest_rect, bitmap, src_rect)
src_rect = Rect.new(0, 0, margin, bitmap.height)
self.contents.blt(x - margin, y, bitmap, src_rect)
src_rect = Rect.new(bitmap.width - margin, 0, margin, bitmap.height)
self.contents.blt(x + width, y, bitmap, src_rect)
end
#--------------------------------------------------------------------------
# ☆ ATK值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_atk_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 800
gw = width * actor.atk / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ DEF值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_def_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 800
gw = width * actor.def / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ SPI值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_spi_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 800
gw = width * actor.spi / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ AGI值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_agi_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 800
gw = width * actor.agi / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ HIT值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_hit_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 800
gw = width * actor.hit / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ EVA值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_eva_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 75
gw = width * actor.eva / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ☆ CRI值槽描画
# type : HP (0) MP (1)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_cri_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = 75
gw = width * actor.cri / max
gc1 = parameter_gauge_color1
gc2 = parameter_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ● EXP情报描画
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
#--------------------------------------------------------------------------
def draw_exp_info_GS(actor, x, y, width = 120)
s1 = actor.exp_s
s2 = actor.next_rest_exp_s
xr = x + width
draw_actor_exp_gauge(actor, x, y, width)
s_next = sprintf(Vocab::ExpNext, Vocab::level)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 60, WLH, "NEXT")
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width, WLH, s2, 2)
end
#--------------------------------------------------------------------------
# ● EXP值槽描画
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_actor_exp_gauge(actor, x, y, width = 120)
draw_gauge_base(x, y, width)
max = actor.next_max_exp
gw = width * (max - actor.next_rest_exp) / max
gc1 = exp_gauge_color1
gc2 = exp_gauge_color2
self.contents.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color)
self.contents.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2)
end
#--------------------------------------------------------------------------
# ● 绘制角色能力值
# actor : 角色
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# type : 能力值类型(0-3)
#--------------------------------------------------------------------------
def draw_actor_parameter(actor, x, y, type)
case type
when 0
parameter_name = Vocab::atk
parameter_value = actor.atk
when 1
parameter_name = Vocab::def
parameter_value = actor.def
when 2
parameter_name = Vocab::spi
parameter_value = actor.spi
when 3
parameter_name = Vocab::agi
parameter_value = actor.agi
#------------------------------------------------------添加
when 4
parameter_name ="命中"
parameter_value = actor.hit
when 5
parameter_name = "回避修正"
parameter_value = actor.eva
when 6
parameter_name = "要害修正"
parameter_value = actor.cri
#------------------------------------------------------添加
end
self.contents.font.color = system_color
self.contents.draw_text(12, y, 120, WLH, parameter_name)
self.contents.font.color = normal_color
self.contents.draw_text(60, y, 36, WLH, parameter_value, 2)
end
def draw_system_text(x, y, width, height, str, align = 0, size = 20)
self.contents.font.color = system_color
self.contents.font.size = size
self.contents.draw_text(x, y, width, height, str, align)
self.contents.font.color = normal_color
self.contents.font.size = 20
end
#--------------------------------------------------------------------------
# ● 绘制物品
# item : 物品(技能、武器、防具也合用)
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# enabled : 有效化标志,为 false 时则物品半透明化。
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true)
if item != nil
draw_icon(item.icon_index, x, y, enabled)
self.contents.font.color = normal_color
self.contents.font.color.alpha = enabled ? 255 : 128
self.contents.draw_text(x + 24, y, 172, WLH, item.name)
end
end
#--------------------------------------------------------------------------
# ● 绘制金钱单位
# value : 数目
# x : 描画目标 X 坐标
# y : 描画目标 Y 坐标
# width : 描画目标宽度
#--------------------------------------------------------------------------
def draw_currency_value(value, x, y, width)
cx = contents.text_size(Vocab::gold).width
self.contents.font.color = normal_color
self.contents.draw_text(x, y, width-cx-2, WLH, value, 2)
self.contents.font.color = system_color
self.contents.draw_text(x, y, width, WLH, Vocab::gold, 2)
end
end
复制代码
就是
现实状态.jpg
(43.52 KB, 下载次数: 20)
下载附件
保存到相册
2010-11-2 21:00 上传
理想状态.png
(141.82 KB, 下载次数: 15)
下载附件
保存到相册
2010-11-2 21:00 上传
作者:
迷路子
时间:
2010-11-2 21:12
你在menustatus中要调用啊……
把function写好但不调用还是白搭啊
作者:
反斗奇彬
时间:
2010-11-2 21:34
回复
迷路子
的帖子
在menustatus调用?不是应该在Window_Status添加吗?我只要在状态画面能显示值槽的
作者:
反斗奇彬
时间:
2010-11-10 11:15
其实,这个问题很多人都遇到吧,为什么没人帮我啊
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1