赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 2640 |
最后登录 | 2013-2-28 |
在线时间 | 6 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 6 小时
- 注册时间
- 2009-9-7
- 帖子
- 140
|
7楼
楼主 |
发表于 2009-9-19 20:31:50
|
只看该作者
6# 青龙
有好多》请问这个怎么用 原帖地址 http://rpg.blue/htm/Topic_30227.htm
class Window_Base
#-------------------------------------------------------------------------
# 描绘血槽 (傻瓜级)
#-------------------------------------------------------------------------
def draw_hp_bar(x, y, min, max, width, height,
bar_color = Color.new(150, 0, 0, 255) )
# 描绘背景
self.contents.fill_rect(x, y, width, height, Color.new(50, 50, 50, 255))
# 描绘血槽
self.contents.fill_rect(x + 1, y + 1, (width - 2) * (min / max.to_f), height - 2, bar_color)
end
#-------------------------------------------------------------------------
# 描绘渐变血槽 (美观级)
#-------------------------------------------------------------------------
def draw_hp_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
# 描绘背景
self.contents.fill_rect(x, y, width, height, Color.new(50, 50, 50, 255))
# 描绘血槽
for i in 1..( (min / max) * width -1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + 1 + i, y + 1, 1, height - 2, Color.new(r, g, b, a))
end
end
#-------------------------------------------------------------------------
# 描绘有倾斜度渐变血槽 (进阶级)
#-------------------------------------------------------------------------
def draw_hp_bar(x, y, min, max, width = 152, height = 6,
bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
#描绘边框
for i in 0..height
self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
end
# 描绘背景
for i in 1..(height - 1)
r = 100 * (height - i) / height + 0 * i / height
g = 100 * (height - i) / height + 0 * i / height
b = 100 * (height - i) / height + 0 * i / height
a = 255 * (height - i) / height + 255 * i / height
self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
end
# 描绘血槽
for i in 1..( (min / max) * width - 1)
for j in 1..(height - 1)
r = bar_color.red * (width - i) / width + end_color.red * i / width
g = bar_color.green * (width - i) / width + end_color.green * i / width
b = bar_color.blue * (width - i) / width + end_color.blue * i / width
a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
end
end
end
end |
|