I have this Hud, but it's lagging because of it constantly refreshing. Can anyone help me reduce the lag? Before I had a Hud, and got rid of most of the lag by having it only refresh if the player's HP/MP/EXP had changed. But as this has bars for all of the party's HP, as well as the HP/MP/EXP of the main character, I'm not sure how I'd go about doing that. A also plan on having the player's HP/MP rise as he walks, so I'm not sure if that's going to work to remove lag.
Code:
#==============================================================================
# ** Window_HUD
#------------------------------------------------------------------------------
# This window displays the HUD
#==============================================================================
class Window_HUD < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(363-16, 232-16-2, 103+32, 75+32)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 12
self.contents.font.color = Color.new(0, 0, 0)
self.z = 9999
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
x = 0 + 34
y = i * 14 + 8
self.contents.draw_hp_picture(x, y, actor.hp, actor.maxhp)
self.contents.draw_text(x + 1, y, width, 12, actor.name)
end
now = $game_party.actors[0].now_exp
nex = $game_party.actors[0].next_exp
hp = $game_party.actors[0].hp
hpm = $game_party.actors[0].maxhp
mp = $game_party.actors[0].sp
mpm = $game_party.actors[0].maxsp
self.contents.draw_hp_picture_vertical(0, 2, hp, hpm, 'playerback', 'playerhp')
self.contents.draw_hp_picture_vertical(9, 2, mp, mpm, 'playerback', 'playermp')
self.contents.draw_hp_picture_vertical(18, 2, now, nex, 'playerback', 'playerxp')
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
refresh
end
end