Reverse Emptying Bars

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

    I tried looking for this in the Master Script List/Google, but to no avail.

    I'm looking for a way to have bars empty/fill in reverse (so basically they empty from the left to the right, instead of from the right to the left).

    I don't think an example is necessary but I'll provide one anyway.

    Spoiler
    wjbfi9.png
    Notice how the bar is empying? I'm looking for that. Any help is appreciated!
  2. Maybe a snippet like this can help:

    Spoiler
    #==============================================================================|# ** You need not edit this part as it's about how this snippet works |#------------------------------------------------------------------------------|#------------------------------------------------------------------------------|# * Edit class: Window_Base |#------------------------------------------------------------------------------|class Window_Base < Window #----------------------------------------------------------------------------| # Rewrite method: draw_actor_hp | #----------------------------------------------------------------------------| def draw_actor_hp(actor, x, y, width = 124) # Rewritten to fill the hp gauge from right to left draw_gauge(x + width * (1 - actor.hp_rate), y, width * actor.hp_rate, 1, hp_gauge_color1, hp_gauge_color2) # change_color(system_color) draw_text(x, y, 30, line_height, Vocab::hp_a) draw_current_and_max_values(x, y, width, actor.hp, actor.mhp, hp_color(actor), normal_color) end # draw_actor_hp #----------------------------------------------------------------------------| # Rewrite method: draw_actor_mp | #----------------------------------------------------------------------------| def draw_actor_mp(actor, x, y, width = 124) # Rewritten to fill the mp gauge from right to left draw_gauge(x + width * (1 - actor.mp_rate), y, width * actor.mp_rate, 1, mp_gauge_color1, mp_gauge_color2) # change_color(system_color) draw_text(x, y, 30, line_height, Vocab::mp_a) draw_current_and_max_values(x, y, width, actor.mp, actor.mmp, mp_color(actor), normal_color) end # draw_actor_mp #----------------------------------------------------------------------------| # Rewrite method: draw_actor_tp | #----------------------------------------------------------------------------| def draw_actor_tp(actor, x, y, width = 124) # Rewritten to fill the tp gauge from right to left draw_gauge(x + width * (1 - actor.tp_rate), y, width * actor.tp_rate, 1, tp_gauge_color1, tp_gauge_color2) # change_color(system_color) draw_text(x, y, 30, line_height, Vocab::tp_a) change_color(tp_color(actor)) draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2) end # draw_actor_tpend # Window_Base#==============================================================================|
    It might raise some compatibility issues though :)
  3. EDIT: Okay, I see where I messed up- but now it seems the bar offsets to the right whenever it empties?
  4. Yeah, I've made a serious mistake, so try this instead:

    Spoiler
    Code:
    #==============================================================================|#  ** You need not edit this part as it's about how this snippet works         |#------------------------------------------------------------------------------|#------------------------------------------------------------------------------|#  * Edit class: Window_Base                                                   |#------------------------------------------------------------------------------|class Window_Base < Window  #----------------------------------------------------------------------------|  #  Rewrite method: draw_gauge                                                |  #----------------------------------------------------------------------------|  def draw_gauge(x, y, width, rate, color1, color2)    fill_w = (width * rate).to_i    gauge_y = y + line_height - 8    contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)    # Rewritten to fill the gauge from right to left    contents.gradient_fill_rect(x + (width * (1 - rate)).to_i, gauge_y, fill_w + 1, 6, color1, color2)    #  end # draw_gaugeend # Window_Base#==============================================================================|
  5. The bar still seems to "offset" a bit to the right when it begins to empty. 

    Spoiler
    2sbmzbq.png
    See how it shifts to the right?

    The shape of the bar looks different because a picture is being draw over top the bar. That wouldn't affect the bar's position though. 
  6. So it seems to me that you're using some custom scripts to draw the bars. I've tested using a vanilla RMVXA project and your issue doesn't happen, so I may have to know how those custom scripts draw the bar if there's any.

    Edit: This snippet should be a bit better for dealing with your issue:

    Spoiler
    Code:
    #==============================================================================|#  ** You need not edit this part as it's about how this snippet works         |#------------------------------------------------------------------------------|#------------------------------------------------------------------------------|#  * Edit class: Window_Base                                                   |#------------------------------------------------------------------------------|class Window_Base < Window  #----------------------------------------------------------------------------|  #  Rewrite method: draw_gauge                                                |  #----------------------------------------------------------------------------|  def draw_gauge(x, y, width, rate, color1, color2)    # Rewritten to fill the gauge from right to left    fill_w = (width * (1 - rate)).to_i    #    gauge_y = y + line_height - 8    contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)    # Rewritten to fill the gauge from right to left    contents.gradient_fill_rect(x + fill_w, gauge_y, width - fill_w, 6, color1, color2)    #  end # draw_gaugeend # Window_Base#==============================================================================|
  7. Nothing about the draw method is being changed, I'm using what you provided, with a picture drawn atop. I'll see what happens with this new version.