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.

How to refresh, dispose, and call by button ?

Jason

Awesome Bro

I'm in the process of making a HUD with some extra add-ons, so far all is working well, But I've ran into a few problems, When I go onto the menu, the HUD is still showing, so I think a dispose is needed here, also, not sure if/why it would be needed, but a refresh somewhere in the script ?
Lastly, well, let me explain first...
I have it on a conditional branch, when Q is pressed (L in the game), it will show the HUD for 50 frames, which works great, but that means I have to put an event on each map or whatever, however...
Is there a way I can make it so if a button is HELD, such as Q, the HUD will show, but as soon as I let go of Q, the HUD will disappear ?

Thanks to any help given.
 

poccil

Sponsor

This would be best solved by conditionally displaying the window on update (the
update method below is from the HUD's class, which is assumed to derive from Window):

Code:
  def update
    self.visible=Input.press?(Input::L)
    # ... rest of update method
    super
  end
 

khmp

Sponsor

Yes. A window has a boolean that enables/disables it from being seen. Window.visible.

So the trick is to just make the HUD window but make it invisible until the Q is being depressed than toggle it on. Else turn this flag to false.

Code:
class Scene_Map
  alias_method :jbri_hudwindow_main, :main
  alias_method :jbri_hudwindow_update, :update
  def main
    @hudwindow = Window_JbristHUD.new
    jbri_hudwindow_main
    @hudwindow.dispose
  end

  def update
    @hudwindow.update
    Input.press?(Input::L) ? @hudwindow.visible = true : @hudwindow.visible = false
    jbri_hudwindow_update
  end
end

This way it won't show on any other screen but Scene_Map. To install this just insert an empty section above and paste this code. I'm unsure on what your HUD object is named so you'll have to change that inside main.
See line:
Code:
@hudwindow = Window_JbristHUD.new
If you have any trouble with it just let me know.

poccil you totally knifed me.  :sad:

Good luck with it jbrist!  :thumb:
 

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