E aí galera! Para quem manja aí e puder me ajudar, creio que seja simples. É o seguinte, queria fazer a barra de uma HUD descer na vertical, de cima para baixo. Desde já agradeço! :Okay_fix:
Código:
class Sprite_HUD < Sprite
def initialize(viewport)
super(viewport)
self.bitmap = Bitmap.new(400, 100)
self.bitmap.font.size = 16
update
end
def update
return if $game_party.members.size <= 0
super
self.visible = !$game_player.transparent
if $game_player.screen_x <= self.bitmap.width+16 &&
$game_player.screen_y <= self.bitmap.height+16
self.opacity -= 10 if self.opacity > 0
elsif self.opacity < 255
self.opacity += 10
end
refresh if something_changed?
end
def refresh
self.bitmap.clear
@actor = $game_party.members[0]
refresh_hp
refresh_mp
refresh_exp
end
def refresh_hp
@hp = @actor.hp
hpbar = Cache.system("hp")
self.bitmap.blt(4, 4, base, base.rect)
hprect = Rect.new(0, 0, hpbar.width*@actor.hp/@actor.mhp, hpbar.height)
self.bitmap.blt(9, 9, hpbar, hprect)
end
def refresh_mp
@mp = @actor.mp
mpbar = Cache.system("mp")
mprect = Rect.new(0, 0, mpbar.width*@actor.mp/@actor.mmp, mpbar.height)
self.bitmap.blt(283, 9, mpbar, mprect)
end
def refresh_exp
@lvl = @actor.level
@xp = @actor.exp
expbar = Cache.system("exp")
if @actor.nxp > 0
exprect = Rect.new(0, 0, expbar.width*@actor.cxp/@actor.nxp, expbar.height)
self.bitmap.blt(108, 41, expbar, exprect)
end
end
def something_changed?
return true if @actor != $game_party.members[0]
return true if @hp != $game_party.members[0].hp
return true if @mp != $game_party.members[0].mp
return true if @lvl != $game_party.members[0].level
return true if @xp != $game_party.members[0].exp
return false
end
def base
Cache.system("Base")
end
end
#------------------------------------------------------------------------------
class Spriteset_Map
alias abshud_spmap_create_viewports create_viewports
alias abshud_spmap_update update
alias abshud_spmap_dispose dispose
def create_viewports
abshud_spmap_create_viewports
crate_hud
end
def update
abshud_spmap_update
update_hud
end
def dispose
abshud_spmap_dispose
dispose_hud
end
def crate_hud
@sprite_hud = Sprite_HUD.new(@viewport3)
end
def update_hud
@sprite_hud.update
end
def dispose_hud
@sprite_hud.dispose
end
end