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.

[Resolved] Showing HUD

Jason

Awesome Bro

Hi,

So I thought I'd do a little script editing with RMVX to get used to RGSS2 (Wow it's so much easier than RGSS...), but I've come across a problem;

Code:
 

  def showing_hud

    if Input.trigger?(Input::L)

      @hud_window1.visible = true

      @hud_window2.visible = true

    else

      @hud_window1.visible = false

      @hud_window2.visible = false

    end

  end

 

As you can see above, if L (Q on Keyboard) is pressed, it's supposed to show the HUD (Seperated into two windows), so it works, except when I press Q, the HUD flashes on and off really quick, is there a way to prevent this from happening, for example, is there a way to insert a wait into the script to allow the HUD to appear ?

Also, I'd like to know, what would I have to add to make it so if I press Q again, the HUD will go away, I was thinking;

Code:
 

  def showing_hud

    if Input.trigger?(Input::L)

      @hud_window1.visible = true

      @hud_window2.visible = true

    else

      if Input.trigger?(Input::L)

      if @hud_window1.visible = true

      if @hud_window2.visible = true

        @hud_window1.visible = false

        @hud_window2.visible = false

      end

    end

  end

 

However I haven't tested it yet, I'd like to make sure I'm on the right track with this (Although I doubt it, lol)

Thanks.
 
Its because the HUD only is set to appear if the L is pressed, rather than toggling. Try this instead:

Code:
   def showing_hud

     if Input.trigger?(Input::L)

       @hud_window1.visible = !@hud_window1.visible

       @hud_window2.visible = !@hud_window2.visible

     end

   end

It's a quick trick to change true to false and false to true.

bool = !bool
 

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