Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[RGSS2/VX] Need help with this HUD.

Jason

Awesome Bro

Hey, so here's my code, pretty simple since I've just started it;

Code:
 

#==============================================================================

# ** Window_HUD

#------------------------------------------------------------------------------

#  This window displays the HUD

#==============================================================================

class Window_HUD < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     x : window X coordinate

  #     y : window Y coordinate

  #--------------------------------------------------------------------------

  def initialize

    super(32, 64, 480, 96)

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    

    for actor in $game_party.members

      draw_actor_name(actor, 0, 4)

    end

    

    self.contents.draw_text(120, 0, 120, 32, "Hello")

  end

  

end

 

Obviously it's going to change and show more info when I've done, but I've got a few... problems/requests.

Right now, I've got it set to a common event, when a switch is turned on, the HUD shows up, and when I display text (Someone talking) I turn the switch off to remove the HUD so it doesn't get in the way, it's working fine with a common event, but having to place the event in every map seems like a pain in the arse, and I'd like to know how to do this through the script, since I can't remember how to do it, lol. Basically, simpler explanation, the HUD only shows while a switch is turned on.

Also, I don't like the windowskin around the hud, now I've tried changing this with back_opacity = 0, but that's just not giving me any results whatsoever, any help here?

Last question, how would I display an image in the window based on a variable? I'm trying to display hearts in it (Lives obviously), I'm wanting to include 3 hearts in a row, and like, if the variable (lives) is equal to 3, all 3 show up, if it's 2, get rid of one of 'em, if 1, get rid of 2 of 'em, and so on like that. I could do this with events and pictures, but I'd rather do it inside a script since it'd make my life easier... I assume.

So yeah, I've not got much done (It's basically just a copy/paste job from another window and change stuff, lol...), but hopefully with help, I'll have something presentable.
 
Edited...

[rgss]if $game_switches[11]
  @hud_sprite.visible = true
else
  @hud_sprite.visible = false
end if $game_switches[11] != @hud_sprite.visible
 
#or... simplified version
 
if $game_switches[11] != @hud_sprite.visible
  @hud_sprite.visible = $game_switches[11]
end
[/rgss]

back_opacity only changes the opacity of the background of the central part of the window. opacity should make the whole window disappear if set to 0.
 

Jason

Awesome Bro

Okay, so first, for some reason opacity just isn't changing no matter what I try, seriously, I think I'm either missing a brain cell, or well, that's all...

Secondly, for some reason the if statement likes to scream at me and say that "[]" is an undefined method, which I've set to switch 3, when clearly it isn't...
 
If you started using the if statement AFTER $game_switches is initialized (in Scene_Title, command_new_game method - when you're going to appear on a map and begin your journey), there's no reason it should be telling you it can't perform such a simple task.

Actually the if statement should be as simple as...

if $game_switches[11] != @hud_sprite.visible
@hud_sprite.visible = $game_switches[11]
end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top