Iae gente, eu estava lendo sobre o gradient_fill_rect, que é usado para criar uma forma com um degradê interno. Bem, pra testar eu criei uma hud, bem simples, que exibe apenas o hp e mp do personagem, achei que ela ficou bonitinha e resolvi postar aqui pra quem quiser xD
Screens
Script
Screens
- Spoiler:
- Spoiler:
Script
- Código:
#===============================================================================
# HUD
#-------------------------------------------------------------------------------
# By Soreto
#===============================================================================
class Hud < Window_Base
def initialize
super(-13,5,220,100)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 0
self.z = 9999
@actor = $game_party.members[0]
#------------------------------------------------
# Align
# 0 - Left | 1 - Center | 2 - Right
#------------------------------------------------
@align = 0
refresh
end
def update
super
refresh if something_changed?
end
def something_changed?
return true if @ohp != @actor.hp
return true if @omp != @actor.mp
return false
end
#------------------------------------------------
# Refresh
#------------------------------------------------
def refresh
self.contents.clear
@ohp = @actor.hp
@omp = @actor.mp
#------------------------------------------------
# Draw Bars
#------------------------------------------------
hpwidth = 175 * @actor.hp / @actor.mhp
mpwidth = 175 * @actor.mp / @actor.mmp
hpbar = self.contents.gradient_fill_rect(5, 40, mpwidth, 15, Color.new(0,0,255), Color.new(30,144,255))
mpbar = self.contents.gradient_fill_rect(5, 10, hpwidth, 15, Color.new(255,0,0), Color.new(255,69,0))
draw_border
draw_text
end
#------------------------------------------------
# Draw Text
#------------------------------------------------
def draw_text
self.contents.font.name = "Verdana"
self.contents.font.size = 15
txt = self.contents.draw_text(5, 10, 175, 15, "#{@actor.hp}/#{@actor.mhp}", @align)
txt2 = self.contents.draw_text(5, 40, 175, 15, "#{@actor.mp}/#{@actor.mmp}", @align)
end
#------------------------------------------------
# Draw Border
#------------------------------------------------
def draw_border
self.contents.blur
@border1 = self.contents.fill_rect(0, 1, width - 32-1, 1, Color.new(0,0,0))
@border2 = self.contents.fill_rect(0, 0, width - 32-3, 1, Color.new(0,0,0))
@border4 = self.contents.fill_rect(0, 65, width - 32-1, 1, Color.new(0,0,0))
@border5 = self.contents.fill_rect(0, 66, width - 32-3, 1, Color.new(0,0,0))
self.contents.blur
end
end
#------------------------------------------------
# Class Scene_Map
#------------------------------------------------
class Scene_Map
alias hud_main main
def main
@Hud = Hud.new
hud_main
@Hud.dispose
end
alias hud_update update
def update
hud_update
@Hud.update
end
end
Última edição por Soreto em Seg Abr 23, 2012 3:12 pm, editado 3 vez(es)