由于不懂RGSS,所以,改造脚本对俺来说真成了一项比画地图写剧本还要艰难的事(仅比找美工简单一点)...
首先先感谢66桑制作了“战斗中显示敌人HP、SP”的脚本并无偿提供给了我们这些新人使用。使用之余,突然想改造一下这个脚本...于是就得到了这样的一段代码:
def carol3_draw_hp_bar(actor, x, y, width = 280) #宽度可调
self.contents.font.color = text_color(8)
self.contents.fill_rect(x-1, y+12, width+2,10, Color.new(225, 0, 0, 185))
w = width * actor.hp / actor.maxhp
self.contents.fill_rect(x, y+13, w,1, Color.new(255, 68, 0, 255))
self.contents.fill_rect(x, y+14, w,2, Color.new(255, 204, 119, 255))
self.contents.fill_rect(x, y+16, w,3, Color.new(255, 238, 0, 255))
self.contents.fill_rect(x, y+19, w,2, Color.new(255, 204, 119, 255))
self.contents.fill_rect(x, y+21, w,1, Color.new(255, 153, 119, 255))
self.contents.fill_rect(x, y+22, w,1, Color.new(0, 0, 0, 255))
# 描绘HP槽的左边框
self.contents.fill_rect(x-2, y+12, 2,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-3, y+13, 3,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+14, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+15, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+16, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+17, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+18, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+19, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-4, y+20, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-3, y+21, 3,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-2, y+22, 2,1, Color.new(255, 255, 255, 255))
# 描绘HP槽的底/顶边框
self.contents.fill_rect(x-2, y+22, 284,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x-2, y+12, 284,1, Color.new(255, 255, 255, 255))
# 描绘HP槽的右边框
self.contents.fill_rect(x+280, y+12, 2,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+13, 3,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+14, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+15, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+16, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+17, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+18, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+19, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+20, 4,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+21, 3,1, Color.new(255, 255, 255, 255))
self.contents.fill_rect(x+280, y+22, 2,1, Color.new(255, 255, 255, 255))
self.contents.draw_text(x-78,y,128,32,"HP:",1)
self.contents.font.color = normal_color
end
于是,便得到了这样的效果:
但是...这样一来脚本就变得十分的冗长,FC新人在此求高人帮忙,有何办法能把上述代码优化一下呢...先性谢过了~
[此贴子已经被作者于2005-6-22 23:58:28编辑过] |