Help - Search - Members - Calendar
Full Version: A HUD that you can turn on and off?
RPG RPG Revolution Forums > Game Engines > RPG Maker XP Discussion
Xim
Hey, I have a part in my game, which is pretty much a survival mini-game. I don't want the player to be able to open the menu during this part but knowing how much health you have is pretty important so what I need is a HUD. I found this script which is pretty nice, but I don't want the hud to always appear and I don't know too much about scripting. Is there a way I can turn it on and off through an event? Such as turning the HUD on when the minigame starts, and then turn it off when it ends?
stripe103
EDIT: I'm trying but right now, the game gets stuck when trying to hide it.
This is what I got now
CODE
#==============================================================================
# ** Window_BasicHUD (By SephirothSpawn)
#------------------------------------------------------------------------------
#  A Simple HUD System shows a HUD on the map, that shows the current actor's
#  HP and SP.
#==============================================================================

#==============================================================================
# ** Window_BasicHUD
#==============================================================================

class Window_BasicHUD < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 224, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 160
    update
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    draw_actor_hp(@actor, 0,  0, 192)
    draw_actor_sp(@actor, 0, 32, 192)
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if @actor != $game_party.actors[0] || @hp != $game_party.actors[0].hp ||
       @sp != $game_party.actors[0].sp
      @actor = $game_party.actors[0]
      @hp = @actor.hp
      @sp = @actor.sp
      refresh
    end
  end
end

#==============================================================================
# ** Scene_Map
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias_method :seph_basichud_scnmap_main, :main
  alias_method :seph_basichud_scnmap_updt, :update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Create HUD
    @hud_window = Window_BasicHUD.new
    $hudvisible = false if $hudvisible == nil
    @hud_window.visible = $hudvisible
    # Original Main
    seph_basichud_scnmap_main
    # Dispose HUD
    @hud_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    @hud_window.visible = $hudvisible
    # Update HUD
    @hud_window.update
    # Original Update
    seph_basichud_scnmap_updt
  end
end
Xim
Well thanks. Any progress is progress. But how do I call up the HUD. I know I'd have to use the "Script" command in the event, but I don't know exactly what to do with it.
stripe103
$hudvisible = and then true or false.
I'll continue trying tomorrow as it is 10.45 P.M. here in Sweden, but until then, someone else have probably allready finished this. Because I'm not sure if I can fix that problem. I'm still learning myself.
Xim
Alright thanks. You've been quite helpful. smile.gif

EDIT: Okay, I got a bit further. I have it so you can turn the HUD off now by changing line 61 to ( $hudvisible == nil if $hudvisible = false ), but it locks up the game. At least I'm getting somewhere though. tongue.gif

EDIT 2: Okay, well after many attempts at trying to fix the code. The best I could do is simply call ( $scene = Scene_Map.new ) to close it. It actually works just fine, so I guess it'll do.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.