幻耶 发表于 2011-8-24 14:26:26

这个脚本修改血条长短和间距的地方在哪里?

是一个用图片代替血槽的脚本,我改成了斜向战斗,所以觉得原来的血条太长了些,想把血条改短到70%并且改小两个角色血条之间的间距,如果只把图片改短似乎显示会出问题。



#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
#  バトル画面でパーティメンバーのステータスを表示するウィンドウです。
#==============================================================================

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, 240, 640, 240)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    @background_window = Window_Base.new(0, 320, 640, 160)
    @background_window.opacity = 0
    @menu = Sprite.new
    @menu.bitmap = RPG::Cache.picture("战斗状态")
    @menu.y = 320
    @menu.z += 1
    @level_up_flags =
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    @background_window.dispose
    @menu.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● レベルアップフラグの設定
  #     actor_index : アクターインデックス
  #--------------------------------------------------------------------------
  def level_up(actor_index)
    @level_up_flags = true
  end
  #--------------------------------------------------------------------------
  # ● レベルアップ表示
  #--------------------------------------------------------------------------
  def refresh_level_up
    for i in 0...$game_party.actors.size
      if @level_up_flags
        bitmap = RPG::Cache.picture("System/Battle-LevelUp")
        src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
        self.contents.blt(i * 160, 0, bitmap, src_rect)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      actor = $game_party.actors
      actor_x = i * 160 + 320
      y = i * (-30) + 50  # XXOO
      draw_actor_hp(actor, actor_x, y + 62, 14)
      draw_actor_sp(actor, actor_x, y + 90, 14)
      draw_actor_hpbar(actor, actor_x + 16, y + 86)
      draw_actor_spbar(actor, actor_x + 16, y + 114)
      draw_actor_state(actor, actor_x, y + 132)
      draw_actor_name(actor, actor_x, y + 36)
    end
  end
  #--------------------------------------------------------------------------
  # ★ HPバー の描画
  #     actor : アクター
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_actor_hpbar(actor, x, y)
    bitmap = RPG::Cache.picture("空槽")
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(x, y, bitmap, src_rect)
    bitmap = RPG::Cache.picture("血槽")
    cx = actor.hp * 100 / actor.maxhp
    src_rect = Rect.new(0, 0, cx, bitmap.height)
    self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # ★ SPバー の描画
  #     actor : アクター
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_actor_spbar(actor, x, y)
    bitmap = RPG::Cache.picture("空槽")
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(x, y, bitmap, src_rect)
    bitmap = RPG::Cache.picture("气槽")
    cx = actor.sp * 100 / actor.maxsp
    src_rect = Rect.new(0, 0, cx, bitmap.height)
    self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # ● HP の描画
  #     actor : アクター
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, size = 16)
    bitmap = RPG::Cache.picture("HP字样")
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(x, y + 4, bitmap, src_rect)
    # HP を描画
    x += 32
    self.contents.font.size = size
    self.contents.font.italic = true
    color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    draw_text_custom(x, y, 42, 32, actor.hp.to_s, color, 2)
    self.contents.font.italic = false
    draw_text_normal(x + 42, y, 16, 32, "/", 1)
    self.contents.font.italic = true
    # MaxHP を描画
    draw_text_normal(x + 54, y, 42, 32, actor.maxhp.to_s, 2)
    self.contents.font.italic = false
  end
  #--------------------------------------------------------------------------
  # ● SP の描画
  #     actor : アクター
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, size = 16)
    bitmap = RPG::Cache.picture("MP字样")
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(x, y + 4, bitmap, src_rect)
    # SP を描画
    x += 32
    self.contents.font.size = size
    self.contents.font.italic = true
    color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    draw_text_custom(x, y, 42, 32, actor.sp.to_s, color, 2)
    self.contents.font.italic = false
    draw_text_normal(x + 42, y, 16, 32, "/", 1)
    self.contents.font.italic = true
    # MaxSP を描画
    draw_text_normal(x + 54, y, 42, 32, actor.maxsp.to_s, 2)
    self.contents.font.italic = false
  end
  #--------------------------------------------------------------------------
  # ★ 文字列(影つき:通常色・無効色あり)の描画
  #--------------------------------------------------------------------------
  def draw_text_custom(x, y, width, height, str, color, align = 0)
    self.contents.font.color = Color.new(36, 24, 16, 224)
    self.contents.draw_text(x + 1, y + 1, width, height, str, align)
    self.contents.font.color = color
    self.contents.draw_text(x, y, width, height, str, align)
  end
  #--------------------------------------------------------------------------
  # ★ 文字列(影つき:通常色)の描画
  #--------------------------------------------------------------------------
  def draw_text_normal(x, y, width, height, str, align = 0)
    self.contents.font.color = Color.new(36, 24, 16, 224)
    self.contents.draw_text(x + 1, y + 1, width, height, str, align)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width, height, str, align)
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    # メインフェーズのときは不透明度をやや下げる
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 192
      self.z = 50
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
      self.z = 200
    end
  end
end

secondsen 发表于 2011-8-24 16:01:14

这要看你的“空槽”“血槽”的图片是什么样子的。。。怎么说呢,这个脚本不是单纯的用精灵显示血条。。。而是bitmap操作。。。这个不太好办。。XP好像不能放大缩小blt,vx才加了这个功能的。。所以呢,最简单的方法就是。。。把图片从新做一下,做成70%大小就可以了。。。。

然后是距离。。注释有drawhp 、 sp什么的就在那里。。。改一下x,y坐标就可以了。。。

幻耶 发表于 2011-8-24 16:10:27

难道是这样改??同时改短图片文件?

#--------------------------------------------------------------------------
# ★ HPバー の描画
#   actor : アクター
#   x   : 描画先 X 座標
#   y   : 描画先 Y 座標
#--------------------------------------------------------------------------
def draw_actor_hpbar(actor, x, y)
    bitmap = RPG::Cache.picture("空槽")
    src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
    self.contents.blt(x, y, bitmap, src_rect)
    bitmap = RPG::Cache.picture("血槽")
    cx = actor.hp *70/ actor.maxhp
    src_rect = Rect.new(0, 0, cx, bitmap.height)
    self.contents.blt(x + 73 - cx, y + 2, bitmap, src_rect)
end

幻耶 发表于 2011-8-24 16:12:59

好像这样就对了。。。

secondsen 发表于 2011-8-24 17:44:30

应该是这样。。具体的工程我也没有,只能提这些建议。。。
页: [1]
查看完整版本: 这个脚本修改血条长短和间距的地方在哪里?