Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
albertibay

Gold text being hidden by picture

Question

hey can you help me guys

I'm making a new hud

So far its going great.

But theres a problem

I'm using a script to show the gold window but only the text

the text should be on top of the hud

but the picture is on top of the text

 

http://www.gdunlimited.net/media/uploads/manager/test2-23878.PNG

 

Here is the script

module Gold_Window #to hide just make a script call Gold_Window.hide
  # Window's horizontal position
  WINDOW_X = 250
  # Window's vertical position
  WINDOW_Y = -20
  # Window's width
  WINDOW_WIDTH = 160
  # Window's height
  WINDOW_HEIGHT = 64
  # Default hide status of the window (true = hidden, false = visible)
  DEFAULT_HIDE = false
 
  @hide = DEFAULT_HIDE
  def self.hidden?
    return @hide
  end
  def self.hide
    @hide = !@hide
  end
end
#==============================================================================
# ** Window_Gold_HUD
#------------------------------------------------------------------------------
#  This window displays amount of gold.
#==============================================================================
class Window_Gold_HUD < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(Gold_Window::WINDOW_X, Gold_Window::WINDOW_Y,
    Gold_Window::WINDOW_WIDTH, Gold_Window::WINDOW_HEIGHT)
    self.contents = Bitmap.new(width - 32, height - 32)
    @old_gold = -1
    @old_hide = Gold_Window.hidden?
    self.opacity = Gold_Window.hidden? ? 0 : 0
    @text_opacity = Gold_Window.hidden? ? 0 : 255
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if @old_gold != $game_party.gold || @old_hide != Gold_Window.hidden?
      self.contents.clear
      self.opacity = Gold_Window.hidden? ? 0 : 0
      @text_opacity = Gold_Window.hidden? ? 0 : 255
      color_normal = Color.new(255, 255, 255, @text_opacity)
      color_system = Color.new(192, 224, 255, @text_opacity)
      cx = contents.text_size($data_system.words.gold).width
      self.contents.font.color = color_normal
      self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
      self.contents.font.color = color_system
      self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
      @old_gold = $game_party.gold
      @old_hide = Gold_Window.hidden?
    end
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias gold_hud_main main
  def main
    @gold_window = Window_Gold_HUD.new
    gold_hud_main
    @gold_window.dispose    
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias gold_hud_update update
  def update
    @gold_window.refresh
    gold_hud_update
  end
end

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hm...I think I know what the problem is. One sec...

 

 

Try this. The edit is on line 8

if it doesn't work, try making Z even higher. If that doesn't work then I probably can't help you.

module Gold_Window #to hide just make a script call Gold_Window.hide
  # Window's horizontal position
  WINDOW_X = 250
  # Window's vertical position
  WINDOW_Y = -20
  # Everything is on it's own layer. changing this will put it behind or in
  # front of other things created via scripts
  WINDOW_Z = 1000
  #-------------------------------------------------------------------------
  # Window's width
  WINDOW_WIDTH = 160
  # Window's height
  WINDOW_HEIGHT = 64
  # Default hide status of the window (true = hidden, false = visible)
  DEFAULT_HIDE = false
 
  @hide = DEFAULT_HIDE
  def self.hidden?
    return @hide
  end
  def self.hide
    @hide = !@hide
  end
end
#==============================================================================
# ** Window_Gold_HUD
#------------------------------------------------------------------------------
#  This window displays amount of gold.
#==============================================================================
class Window_Gold_HUD < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(Gold_Window::WINDOW_X, Gold_Window::WINDOW_Y,
    Gold_Window::WINDOW_WIDTH, Gold_Window::WINDOW_HEIGHT)
    self.contents = Bitmap.new(width - 32, height - 32)
    @old_gold = -1
    @old_hide = Gold_Window.hidden?
    self.opacity = Gold_Window.hidden? ? 0 : 0
    @text_opacity = Gold_Window.hidden? ? 0 : 255
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if @old_gold != $game_party.gold || @old_hide != Gold_Window.hidden?
      self.contents.clear
      self.opacity = Gold_Window.hidden? ? 0 : 0
      @text_opacity = Gold_Window.hidden? ? 0 : 255
      color_normal = Color.new(255, 255, 255, @text_opacity)
      color_system = Color.new(192, 224, 255, @text_opacity)
      cx = contents.text_size($data_system.words.gold).width
      self.contents.font.color = color_normal
      self.contents.draw_text(4, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
      self.contents.font.color = color_system
      self.contents.draw_text(124-cx, 0, cx, 32, $data_system.words.gold, 2)
      @old_gold = $game_party.gold
      @old_hide = Gold_Window.hidden?
    end
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  alias gold_hud_main main
  def main
    @gold_window = Window_Gold_HUD.new
    gold_hud_main
    @gold_window.dispose    
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias gold_hud_update update
  def update
    @gold_window.refresh
    gold_hud_update
  end
end
Edited by Bob423

Share this post


Link to post
Share on other sites
  • 0

I've had this problem before too with a script i was working on before. The problem is the Gold number's Z height, not the huds, but you might want to set that too.

 

bob also forgot to add the Z height to the window initialize, but 10 should be more than enough.

 

so on Line 35 add:

 super(Gold_Window::WINDOW_X, Gold_Window::WINDOW_Y, Gold_Window::WINDOW_Z,

 

And Above Line 55 add:   

 

 

self.z += 11

 

 

Make sure the gold text Z axis is higher than the windows Z axis otherwise it'll show below the hud.

Share this post


Link to post
Share on other sites
  • 0

Error#

 

Script 'Gold Hud' line 36: ArgumentError Occurred

Wrong number of arguments 5 for 4

Share this post


Link to post
Share on other sites
  • 0

Oh goodness I just realized you're trying to display your Hud as a picture...lol

What i said will totally not work, neither will Bob's solution.

 

What you need to do is display the picture inside the window.

To do that you need to add this at the beginning of your script, after your WindowX/Y stuff but before you Initialize.

    #===========================================================================
    # Draw Hud Display
    #===========================================================================
  def draw_hud_display(actor, x, y)
   bitmap = RPG::Cache.picture("hud")
    sw = bitmap.width
    sh = bitmap.height
    src_rect = Rect.new(0, 0, sw, sh)
    self.contents.blt(x, y, bitmap, src_rect)
  end

This will allow your window to display the picture "hud.png" inside.

 

Next you add this in your Refresh after "self.contents.clear" :

 draw_hud_display(@actor, 0, 0)

This will actually draw hud.png.

Now all you have to do is fiddle with the dimensions of the hud. With your current set up it'll only display the hud exactly where the gold is displayed. if you want to add other stuff you'll have to add another window on the left and right with similar codes and basically have the pictures overlap/side by side.

I think a better approach would be one big window for the hud (spanning the whole top) and then have that divided into the different sections you want, ie gold, time, character hp/mp ect...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...