同一张位图中,没有z值这个说法,z值是Sprite,Window等对象才有的属性,不是Bitmap的属性。
如果在同一张Bitmap里面修改遮挡效果,改变一下绘制顺序即可,记住一个原则:后绘制的会覆盖先绘制的。
因此,脚本修改如下:
def draw_actor_hp(actor, x, y, width = 144) bitmap2 = RPG::Cache.icon("HP空槽") self.contents.blt(x, y, bitmap2, Rect.new(0, 0, bitmap2.width, bitmap2.height)) bitmap = RPG::Cache.icon("hp条") width = bitmap.width * actor.hp * 100 / actor.maxhp / 100 self.contents.blt(x + 44, y + 2, bitmap, Rect.new(0, 0, width, bitmap.height)) self.contents.font.size = 15 self.contents.font.bold = true self.contents.font.color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color cx = contents.text_size(actor.hp.to_s).width self.contents.draw_text(x + 85, y-7, cx, 32, actor.hp.to_s) self.contents.font.color = normal_color txt = "/" + actor.maxhp.to_s self.contents.draw_text(x + 85 + cx, y-7, 126, 32, txt) end
def draw_actor_hp(actor, x, y, width = 144)
bitmap2 = RPG::Cache.icon("HP空槽")
self.contents.blt(x, y, bitmap2, Rect.new(0, 0, bitmap2.width, bitmap2.height))
bitmap = RPG::Cache.icon("hp条")
width = bitmap.width * actor.hp * 100 / actor.maxhp / 100
self.contents.blt(x + 44, y + 2, bitmap, Rect.new(0, 0, width, bitmap.height))
self.contents.font.size = 15
self.contents.font.bold = true
self.contents.font.color = actor.hp == 0 ? knockout_color :
actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
cx = contents.text_size(actor.hp.to_s).width
self.contents.draw_text(x + 85, y-7, cx, 32, actor.hp.to_s)
self.contents.font.color = normal_color
txt = "/" + actor.maxhp.to_s
self.contents.draw_text(x + 85 + cx, y-7, 126, 32, txt)
end
|