Estou tentando colocar a hud invisivel quando se aperta uma tecla, é uma scene_map < scene_base. Criei uma condição dentro do update
@hp.opacity = 0 if Input.trigger?(Input::C). Mas não funfou.
Tentei também @hp.visible e não deu. Não estou entendendo por que não está dando certo, se o que fica em loop no scene_base é o update... Sempre que eu apertar a tecla C deveria desativar a hud? Vlw
Script:
class Scene_Map < Scene_Base
alias enter_hud_start start
alias enter_update update
alias enter_hud_terminate terminate
def start
@actor = $game_party.members[0]
enter_hud_start #alias
create_hud
update_variables
end
def update
enter_update #alias
#métodos que vão desenhar a hud, eles vão apagar a hud quando for necessário o update, e desenha-la novamente
draw_hp if hp_need_update?
@hp.opacity = 0 if Input.trigger?(Input::C)
end
def terminate
enter_hud_terminate
dispose_hud
end
def create_hud
create_sprites
create_bitmaps
get_bitmap_size
draw_hp
end
def dispose_hud
@hp.bitmap.dispose
@hp.dispose
end
def create_sprites
@hp = Sprite.new
end
def create_bitmaps
@hp.bitmap = bitmap = Cache.picture('barraenergia')
end
def update_variables
@actor_hp = @actor.hp
@actor_mhp = @actor.mhp
end
def get_bitmap_size
@hpw = @hp.width
@hph = @hp.height
end
def hp_need_update?
return true unless @actor_hp == @actor.hp #Só vai retornar true se o hp do herói NÃO estiver igual ao do próprio herói
return true unless @actor_mhp == @actor.mhp #do máximo hp
end
def draw_hp
@hp.bitmap.clear
@hp.bitmap = Bitmap.new(@hpw,@hph)
hpw = @hpw * @actor.hp / @actor.mhp
hph = @hph
rect = Rect.new(0,0,hpw,hph)
@hp.bitmap.blt(0,0,Cache.picture("barraenergiaCompleta"),rect)
end
end