juniormolinaJue Mar 28, 2013 7:04 pm
Nuevo Usuario
Hola amigos, la cuestión es que he creado una HUD gracias a Generador de Huds, y ps me he basado en la de ReinoRPG HUD pero mejorandola un poco.
Pero tengo un problema, en este script que encontre la HUD desaparece y aparece si se oprime una tecla, o cuando el pj la toca.. este es el script:
Lo que quiero es que esta HUD (la que he creado) tenga esa misma opcion de desaparecer y aparecer, pero no se como hacerlo O.O'' si alguien me puede ayudar se lo agradeceria Aca les dejo la HUD que hize :
AQUI LAS IMAGENES QUE UTILIZE :
(SI VAN A PROBAR LA HUD, A ESTA ULTIMA IMAGEN
DEBEN CAMBIARLE EL NOMBRE POR: 288547BFC)
ASI ES COMO SE VE LA HUD EN EL JUEGO:
NOTA:SI LAS IMAGENES NO SE VEN, ABRIRLA EN UNA NUEVA
PESTAÑA Y CARGAR LA PAG, ASI SE VERAN XD.
Pero tengo un problema, en este script que encontre la HUD desaparece y aparece si se oprime una tecla, o cuando el pj la toca.. este es el script:
- Spoiler:
- Código:
#================================================#
# ¦ ReinoRPG HUD v0.6
# Script: LB
# Translated: Bravo2Kilo
# Toggle key: Kal
#================================================#
puts "HUD Loaded"
module PR_RRPG_HUD
#================================================#
#============= General Settings ===============#
#================================================#
# Post nil if you want to center on screen
# Place a minus sign in front of value to refer to the opposite side.
Position_X = nil
Position_Y = -8
Bottom_of_the_HUD = "Back.png"
Bar_HP = "HP.png"
Bar_MP = "MP.png"
Using_transparency_in_the_entrance = true # Makes the HUD fade when go under it
Using_transparency_in_the_exit = true # FadeOut to disappear in just
Speed = 3 # Speed to FadeIn/FadeOut
Final_Opacity = 255 # Final 0pacity of the HUD
Opacity_Final_Element = 255 # Opacity of the final elements of the HUD
Character_Opacity = 150 # Opacity if the character is under
Opacity_Character_Element = 160 # Opacity of the elements
Switch_Control = 1 # Switch that controls whether the HUD is active or not
# HUD to be active ON and OFF to turn it off.
Number_Character = 1 # The number of character in order according to menu
HUD_Toggle_Show_Key = Input::L # Press this key to show/hide the HUD
# L is the Q key on a keyboard.
# Press F1 in a game to see what the default
# key mappings are.
#==============================================#
#=============== HUD Elements ================#
#==============================================#
# Set to true to display graphic charset (false to not display)
Char_Show = true
Char_X = 46
Char_Y = 66
# Set true to show the character's name (false to not display)
Name_Show = true
Name_Alignment = 1 # 0 = Left | 1 = Center | 2 = Right
Name_X = 15
Name_Y = 27
Name_Width = 134
Name_Color = Color.new(255,255,255)
Name_Font = nil # Font to use, write nil to use the default
Name_Size_of_Font = 17 # Size_of Font
# Set true to show the character's class (false to not display)
Class_Show = true
Class_Alignment = 0 # 0 = Left | 1 = Center | 2 = Right
Class_X = 246
Class_Y = 25
Class_Width = 60
Class_Color = Color.new(255,255,255)
Class_Font = nil # Font to use, write nil to use the default
Class_Size_of_Font = 16 # Size_of Font
# Set true to show the bar that represents the character's HP (false to not display)
HP_Show = true
HP_X = 92
HP_Y = 42
# Set true to show the bar that represents the character's MP (false to not display)
MP_Show = true
MP_X = 92
MP_Y = 59
# Set true to show the value of Current HP bar (false to not display)
Values_HP_Show_Current = true
# Set true to show the maximum value of the HP bar (false to not display)
Values_HP_Show_Total = true
Values_HP_Color = Color.new(255,255,255)
Values_HP_Font = nil # Font to use, write nil to use the default
Values_HP_Size_of_Font = 14 # Size_of Font
Values_HP_X = 92
Values_HP_Y = 44
# Set true to show the value of Current MP bar (false to not display)
Values_MP_Show_Current = true
# Set true to show the maximum value of the MP bar (false to not display)
Values_MP_Show_Total = true
Values_MP_Color = Color.new(255,255,255)
Values_MP_Font = nil # Font to use, write nil to use the default
Values_MP_Size_of_Font = 14 # Size_of Font
Values_MP_X = 92
Values_MP_Y = 59
# Set true to show the character's level (false to not display)
LV_Show = true
LV_Color = Color.new(255,255,255)
LV_Font = nil # Font to use, write nil to use the default
LV_Size_of_Font = 19 # Size_of Font
LV_Width = 30
LV_X = 241
LV_Y = 49
# Set true to show the character of money (false to not display)
Gold_Show = true
Gold_Color = Color.new(255,255,255)
Gold_Font = nil # Font to use, write nil to use the default
Gold_Size_of_Font = 18 # Size_of Font
Gold_X = 281
Gold_Y = 35
Gold_Width = 50
# Set true to show the suffix of play money (false to not display)
Text_Show = true
Text_Color = Color.new(255,255,255)
Text_Font = nil # Font to use, write nil to use the default
Text_Size_of_Font = 15 # Size_of Font
Text_X = 281
Text_Y = 50
Text_Width = 50
Text = "Gold" # Name of game currency
end
#===============================================#
#============ End of Settings ================#
#===============================================#
#============ Top of Script ==================#
#===============================================#
module Cache
#--------------------------------------------------------------------------
# * Get HUD Graphic
# filename : Filename
#--------------------------------------------------------------------------
def self.hud(filename)
load_bitmap("Graphics/Hud/", filename)
end
end
class Scene_Map < Scene_Base
include PR_RRPG_HUD
alias hud_start start
alias hud_update update
alias hud_terminate terminate
def start
active_hud
hud_start
end
def active_hud
unless @hud_has_run_before
$game_switches[Switch_Control] = true
@hud_has_run_before = true
end
@animation_hud1 = Using_transparency_in_the_entrance
@animation_hud2 = Using_transparency_in_the_entrance
@animation_hud_1 = Using_transparency_in_the_exit
@animation_hud_2 = Using_transparency_in_the_exit
@back = Sprite.new
@back.bitmap = Cache.hud(Bottom_of_the_HUD)
@back.opacity = 0 if @animation_hud1 == true
x = Position_X
y = Position_Y
w = @back.width
h = @back.height
x = ( x == nil ? ( 544 - w ) / 2 : ( x < 0 ? ( 544 + x - w ) : x ) )
y = ( y == nil ? ( 416 - h ) / 2 : ( y < 0 ? ( 416 + y - h ) : y ) )
@back.x = x
@back.y = y
@back.z = 190
@wind = Window_Base.new(x-16,y-16,w+32,h+32)
@wind.opacity = 0
@wind.contents_opacity = 0 if @animation_hud2 == true
@wind.z = 195
@wind.contents.font.shadow = false
@id = Number_Character-1
@info = []
@hp = Sprite.new
@hp.bitmap = Bitmap.new(32,32)
@mp = Sprite.new
@mp.bitmap = Bitmap.new(32,32)
@hp.x = HP_X + x
@mp.x = MP_X + x
@hp.y = HP_Y + y
@mp.y = MP_Y + y
@hp.z = 192
@mp.z = 193
@hp.opacity = 0 if @animation_hud2 == true
@mp.opacity = 0 if @animation_hud2 == true
hud_real_update if status_update
end
def terminate
if @animation_hud_1 == true
@back.bitmap.dispose
@back.dispose
end
if @animation_hud_2 == true
@hp.bitmap.dispose
@hp.dispose
@mp.bitmap.dispose
@mp.dispose
@wind.contents.dispose
@wind.dispose
end
hud_terminate
end
def update
if $game_switches[Switch_Control] == true and @hud_keyboard_switch
if @back != nil
if @back.opacity < Final_Opacity and @animation_hud1 == true
@back.opacity += Speed
else
@back.opacity = Final_Opacity
@animation_hud1 = false
end
if @wind.contents_opacity < Opacity_Final_Element and @animation_hud2 == true
@wind.contents_opacity += Speed
@hp.opacity += Speed
@mp.opacity += Speed
else
@wind.contents_opacity = Opacity_Final_Element
@hp.opacity = Opacity_Final_Element
@mp.opacity = Opacity_Final_Element
@animation_hud2 = false
end
else
active_hud
end
else
if @back != nil
if @back.opacity > Speed-1 and @animation_hud_1 == true
@back.opacity -= Speed
else
@back.bitmap.dispose
@back.dispose
@back = nil
@animation_hud_1 = false
end
if @wind.contents_opacity > Speed-1 and @animation_hud_2 == true
@wind.contents_opacity -= Speed
@hp.opacity -= Speed
@mp.opacity -= Speed
else
if @animation_hud_2 == true
@hp.bitmap.dispose
@hp.dispose
@hp = nil
@mp.bitmap.dispose
@mp.dispose
@mp = nil
@wind.contents.dispose
@wind.dispose
@wind = nil
@animation_hud_2 = false
end
end
end
end
if @back != nil
if $game_player.screen_x >= @back.x and $game_player.screen_x <= @back.x + @back.width and
$game_player.screen_y >= @back.y and $game_player.screen_y <= @back.y + @back.height
@back.opacity = Character_Opacity
@hp.opacity = Opacity_Character_Element
@mp.opacity = Opacity_Character_Element
@wind.contents_opacity = Opacity_Character_Element
end
end
hud_real_update if status_update
hud_check_key_toggle
hud_update
end
def hud_real_update
a = $game_party.members[@id]
@wind.contents.clear
@wind.draw_character(a.character_name, a.character_index, Char_X, Char_Y) if Char_Show
if Name_Show
@wind.contents.font.name = Name_Font if Name_Font != nil
@wind.contents.font.color = Name_Color
@wind.contents.font.size = Name_Size_of_Font
@wind.contents.draw_text(Name_X, Name_Y, Name_Width, Name_Size_of_Font, a.name, Name_Alignment)
end
if Class_Show
@wind.contents.font.name = Class_Font if Class_Font != nil
@wind.contents.font.color = Class_Color
@wind.contents.font.size = Class_Size_of_Font
@wind.contents.draw_text(Class_X, Class_Y, Class_Width, Class_Size_of_Font, a.class.name, Class_Alignment)
end
if HP_Show
@hp.bitmap.dispose
@hp.bitmap = Cache.hud(Bar_HP)
@hp.bitmap.clear_rect(Rect.new((@hp.width*a.hp/a.mhp),0,@hp.width,@hp.height))
end
if MP_Show
@mp.bitmap.dispose
@mp.bitmap = Cache.hud(Bar_MP)
@mp.bitmap.clear_rect(Rect.new((@mp.width*a.mp/a.mmp),0,@mp.width,@mp.height))
end
if Values_HP_Show_Current
text = a.hp.to_s
end
if Values_HP_Show_Total
text = a.mhp.to_s
end
if Values_HP_Show_Current and Values_HP_Show_Total
text = a.hp.to_s + "/" + a.mhp.to_s
end
if text != nil
@wind.contents.font.name = Values_HP_Font if Values_HP_Font != nil
@wind.contents.font.color = Values_HP_Color
@wind.contents.font.size = Values_HP_Size_of_Font
@wind.contents.draw_text(Values_HP_X, Values_HP_Y, @hp.width, Values_HP_Size_of_Font, text, 2)
end
text = nil
if Values_MP_Show_Current
text = a.mp.to_s
end
if Values_MP_Show_Total
text = a.mmp.to_s
end
if Values_MP_Show_Current and Values_MP_Show_Total
text = a.mp.to_s + "/" + a.mmp.to_s
end
if text != nil
@wind.contents.font.name = Values_MP_Font if Values_MP_Font != nil
@wind.contents.font.color = Values_MP_Color
@wind.contents.font.size = Values_MP_Size_of_Font
@wind.contents.draw_text(Values_MP_X, Values_MP_Y, @hp.width, Values_MP_Size_of_Font, text, 2)
end
if LV_Show
@wind.contents.font.name = LV_Font if LV_Font != nil
@wind.contents.font.color = LV_Color
@wind.contents.font.size = LV_Size_of_Font
@wind.contents.draw_text(LV_X, LV_Y, LV_Width, LV_Size_of_Font, a.level, 1)
end
if Gold_Show
@wind.contents.font.name = Gold_Font if Gold_Font != nil
@wind.contents.font.color = Gold_Color
@wind.contents.font.size = Gold_Size_of_Font
@wind.contents.draw_text(Gold_X, Gold_Y, Gold_Width, Gold_Size_of_Font, $game_party.gold, 1)
end
if Text_Show
@wind.contents.font.name = Text_Font if Text_Font != nil
@wind.contents.font.color = Text_Color
@wind.contents.font.size = Text_Size_of_Font
@wind.contents.draw_text(Text_X, Text_Y, Text_Width, Text_Size_of_Font, Text, 1)
end
end
def status_update
return false if @wind == nil
a = $game_party.members[@id]
return update_infos if a.id != @info[0]
return update_infos if a.character_name != @info[1]
return update_infos if a.character_index != @info[2]
return update_infos if a.name != @info[3]
return update_infos if a.class_id != @info[4]
return update_infos if a.class.name != @info[5]
return update_infos if a.hp != @info[6]
return update_infos if a.mhp != @info[7]
return update_infos if a.mp != @info[8]
return update_infos if a.mmp != @info[9]
return update_infos if a.level != @info[10]
return update_infos if $game_party.gold != @info[11]
return false
end
def update_infos
a = $game_party.members[@id]
@info[0] = a.id
@info[1] = a.character_name
@info[2] = a.character_index
@info[3] = a.name
@info[4] = a.class_id
@info[5] = a.class.name
@info[6] = a.hp
@info[7] = a.mhp
@info[8] = a.mp
@info[9] = a.mmp
@info[10] = a.level
@info[11] = $game_party.gold
return true
end
def hud_check_key_toggle
@hud_keyboard_switch = true if @hud_keyboard_switch.nil?
if Input.trigger?(HUD_Toggle_Show_Key)
@hud_keyboard_switch = !@hud_keyboard_switch
end
end
end
Lo que quiero es que esta HUD (la que he creado) tenga esa misma opcion de desaparecer y aparecer, pero no se como hacerlo O.O'' si alguien me puede ayudar se lo agradeceria Aca les dejo la HUD que hize :
- Spoiler:
- Código:
module HUDWidgets
#----------
class WidgetBase < Sprite
def initialize(name, x, y, z)
super()
@name = name
self.x, self.y, self.z = x, y, z
end
def z=(v)
super(v + 60)
end
def z
return super() - 60
end
end
#----------
class ImageWidget < WidgetBase
attr_accessor :zoom_x, :zoom_y
def initialize(name, x, y, z, w, h, a, param, text, idx)
super(name, x, y, z)
@iw, @ih = w, h
self.opacity = a
@param, @text, @idx = param, text, idx
case @param
when 0
bmp = self.bitmap = Cache.picture(@text)
when 1
update_char
end
#-----
@zoom_x_base = @iw.to_f / self.width
@zoom_y_base = @ih.to_f / self.height
self.zoom_x = 1.0
self.zoom_y = 1.0
end
def zoom_x=(v)
@zoom_x = v.to_f
super(@zoom_x_base * @zoom_x)
end
def zoom_y=(v)
@zoom_y = v.to_f
super(@zoom_y_base * @zoom_y)
end
def update_char
return unless @param == 1
actor = $game_party.leader
bmp = self.bitmap = Cache.character(actor.character_name)
sign = actor.character_name[/^[!$]./]
#-----
if sign and sign.include?('$')
cw, ch = bmp.width / 3, bmp.height / 4
else
cw, ch = bmp.width / 12, bmp.height / 8
end
n = actor.character_index
self.src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
self
end
end
#----------
class TextWidget < WidgetBase
def initialize(name, x, y, z, param, text, id, fname, fsize, fbold, fitalic, fshadow, fcolor, foutline, foutline_color, tw, th, fix_from)
super(name, x, y, z)
#-----
@fsize = fsize
@fix_from = fix_from
@initial_width = nil
#-----
@font = Font.new(fname, fsize)
@font.bold = fbold
@font.italic = fitalic
@font.shadow = fshadow
@font.outline = foutline
@font.out_color = foutline_color
@fbmp = Bitmap.new(1, 1)
@fbmp.font = @font
#-----
@param, @text, @id = param, text, id
@tw, @th = tw, th
#-----
r = @fbmp.text_size('Text')
@font.size *= (@tw.to_f / r.width)
#-----
@fbmp.font = @font
#-----
self.oy = (((r.height * (@tw.to_f / r.width)) * (1.0 - (r.width / @tw.to_f))) * 0.5).ceil
#-----
update
end
def update
actor = $game_party.leader
case @param
when 3 # HP/Max HP
str = (@text % [actor.hp, actor.mhp]) rescue (actor.hp + '/' + actor.mhp)
when 6 # MP/Max MP
str = (@text % [actor.mp, actor.mmp]) rescue (actor.mp + '/' + actor.mmp)
when 9 # EXP/Next Level EXP
str = (@text % [actor.exp, actor.next_level_exp]) rescue (actor.exp + '/' + actor.next_level_exp)
when 10 # LVL
str = (@text % actor.level) rescue actor.level.to_s
when 11 # Map Name
str = (@text % $game_map.display_name) rescue ''
when 12 # Actor's Name
str = (@text % actor.name) rescue ''
when 13 # Actor's Class
str = (@text % actor.class.name) rescue ''
when 14 # Gold Amount
str = (@text % $game_party.gold) rescue '0'
else
return
end
#-----
self.bitmap.dispose if self.bitmap and not self.bitmap.disposed?
return if str.empty?
#-----
r = @fbmp.text_size(str)
bmp = self.bitmap = Bitmap.new(r.width + 32, r.height)
bmp.font = @font
bmp.draw_text(bmp.rect, str, 0)
#-----
@initial_width ||= self.width
#-----
case @fix_from
when 0
self.ox = 0
when 1
self.ox = (self.width - @initial_width) / 2
when 2
self.ox = self.width - @initial_width
end
end
end
end
class Scene_Map < Scene_Base
#----------
alias :hud_alias_start :start
alias :hud_alias_update :update
alias :hud_alias_p_term :terminate
#----------
def start
hud_alias_start
start_hud
end
#-----
def start_hud
@actor_info_cache, @var_info_cache, @hud_widgets = {}, {}, {}
@hud_widgets[0] = HUDWidgets::ImageWidget.new('Back', 3, 335, 0, 540, 83, 255, 0, '288547BFC.png', 1)
@hud_widgets[1] = HUDWidgets::ImageWidget.new('HP', 110, 368, 1, 346, 8, 255, 0, '127C01A03.png', 1)
@hud_widgets[2] = HUDWidgets::ImageWidget.new('MP', 110, 383, 2, 346, 9, 255, 0, '32A67D18B.png', 1)
@hud_widgets[3] = HUDWidgets::ImageWidget.new('EXP', 109, 397, 3, 346, 5, 255, 0, '0F21C3F53.png', 1)
@hud_widgets[4] = HUDWidgets::ImageWidget.new('Object4', 32, 369, 4, 32, 32, 255, 1, '', 0)
@hud_widgets[6] = HUDWidgets::TextWidget.new('Object6', 70, 341, 5, 12, '%s', 0, 'Arial', 10, true, true, true, Color.new(255, 255, 255, 255), false, Color.new(0, 0, 0, 255), 25, 10,0)
@hud_widgets[7] = HUDWidgets::TextWidget.new('Object7', 308, 342, 6, 11, '%s', 0, 'Arial', 10, true, true, true, Color.new(255, 255, 255, 255), false, Color.new(0, 0, 0, 255), 25, 10,0)
@hud_widgets[8] = HUDWidgets::TextWidget.new('Object8', 485, 378, 7, 14, '%d', 0, 'Arial', 12, true, false, true, Color.new(255, 255, 255, 255), false, Color.new(0, 0, 0, 255), 29, 12,1)
@hud_widgets[9] = HUDWidgets::TextWidget.new('Object9', 150, 341, 8, 10, '%d', 0, 'Arial', 11, true, true, true, Color.new(255, 255, 255, 255), false, Color.new(0, 0, 0, 255), 28, 11,0)
@hud_widgets[10] = HUDWidgets::TextWidget.new('Object10', 212, 341, 9, 13, '%s', 0, 'Arial', 11, true, true, true, Color.new(255, 255, 255, 255), false, Color.new(0, 0, 0, 255), 28, 11,0)
@hud_widgets[11] = HUDWidgets::TextWidget.new('Object11', 404, 366, 10, 3, '%d/%d', 0, 'Arial', 11, true, true, false, Color.new(255, 255, 255, 255), true, Color.new(165, 42, 42, 255), 28, 11,1)
@hud_widgets[12] = HUDWidgets::TextWidget.new('Object12', 405, 382, 11, 6, '%d/%d', 0, 'Arial', 11, true, true, false, Color.new(255, 255, 255, 255), true, Color.new(30, 144, 255, 255), 28, 11,1)
@hud_widgets[13] = HUDWidgets::TextWidget.new('Object13', 413, 397, 12, 9, '%d/%d', 0, 'Arial', 9, true, true, false, Color.new(255, 255, 255, 255), true, Color.new(255, 165, 0, 255), 22, 9,1)
update_hud
end
#----------
def update
hud_alias_update
update_hud
end
#-----
def update_hud
actor = $game_party.leader
if @actor_info_cache[:char_hp] != actor.hp or @actor_info_cache[:char_mhp] != actor.mhp
@hud_widgets[1].zoom_x = (actor.hp.to_f / actor.mhp)
@hud_widgets[11].update
@actor_info_cache[:char_hp], @actor_info_cache[:char_mhp] = actor.hp, actor.mhp
end
if @actor_info_cache[:char_mp] != actor.mp or @actor_info_cache[:char_mmp] != actor.mmp
@hud_widgets[2].zoom_x = (actor.mp.to_f / actor.mmp)
@hud_widgets[12].update
@actor_info_cache[:char_mp], @actor_info_cache[:char_mmp] = actor.mp, actor.mmp
end
if @actor_info_cache[:char_exp] != actor.exp or @actor_info_cache[:char_nl_exp] != actor.next_level_exp
@hud_widgets[3].zoom_x = (actor.exp.to_f / actor.next_level_exp)
@hud_widgets[13].update
@actor_info_cache[:char_exp], @actor_info_cache[:char_nl_exp] = actor.exp, actor.next_level_exp
end
if @actor_info_cache[:char_name] != actor.character_name or @actor_info_cache[:char_idx] != actor.character_index
@hud_widgets[4].update_char
@actor_info_cache[:char_name] = actor.character_name
@actor_info_cache[:char_idx] = actor.character_index
end
if @actor_info_cache[:char_name] != actor.name
@hud_widgets[6].update
@actor_info_cache[:char_name] = actor.name
end
if @actor_info_cache[:map_name] != $game_map.display_name
@hud_widgets[7].update
@actor_info_cache[:map_name] = $game_map.display_name
end
if @actor_info_cache[:party_gold] != $game_party.gold
@hud_widgets[8].update
@actor_info_cache[:party_gold] = $game_party.gold
end
if @actor_info_cache[:char_level] != actor.level
@hud_widgets[9].update
@actor_info_cache[:char_level] = actor.level
end
if @actor_info_cache[:char_class] != actor.class.name
@hud_widgets[10].update
@actor_info_cache[:char_class] = actor.class.name
end
end
#----------
def terminate
hud_alias_p_term
hud_dispose
end
#-----
def hud_dispose
@hud_widgets.each_value {|hw| hw.dispose }
end
#----------
end
AQUI LAS IMAGENES QUE UTILIZE :
(SI VAN A PROBAR LA HUD, A ESTA ULTIMA IMAGEN
DEBEN CAMBIARLE EL NOMBRE POR: 288547BFC)
ASI ES COMO SE VE LA HUD EN EL JUEGO:
NOTA:SI LAS IMAGENES NO SE VEN, ABRIRLA EN UNA NUEVA
PESTAÑA Y CARGAR LA PAG, ASI SE VERAN XD.
Última edición por juniormolina el Jue Mar 28, 2013 7:24 pm, editado 1 vez (Razón : quite el Center)