Bar Opacity for Inactive Members

● ARCHIVED · READ-ONLY
Started by Rello 2 posts View original ↗
  1. Hey all,

    Pretty micro request. As some of you may noticed, the program changes an inactive battle actor's face somewhat transparent when viewed in the menu. I was wondering if someone would be able to write a small snippet that turns the HP and MP bars translucent as well (by the same value of the faces)? Any help is appreciated, thanks.
  2. Code:
    class Window_Base < Window
      #--------------------------------------------------------------------------
      # * Draw Enabled Gauge
      #	 rate	: Rate (full at 1.0)
      #	 color1  : Left side gradation
      #	 color2  : Right side gradation
      #	 enabled : Enabled flag. When false, draw semi-transparently.
      #--------------------------------------------------------------------------
      def draw_enabled_gauge(x, y, width, rate, color1, color2, enabled = true)
    	fill_w = (width * rate).to_i
    	gauge_y = y + line_height - 8
    	bc = gauge_back_color
    	bc.alpha = color1.alpha = color2.alpha = enabled ? 255 : translucent_alpha
    	contents.fill_rect(x, gauge_y, width, 6, bc)
    	contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
      end
    end
    Basically, I took the original Window_Base#draw_gauge method and made a new one with an extra argument that determines whether the gauges are drawn semi-transparently.

    Color objects have four properties: red, green, blue, and alpha. Alpha is a public instance variable so you can modify the value easily. I suggest looking up Color in the VX Ace help file if you want to read a bit more.