Project1

标题: 请教小改一下状态条 [打印本页]

作者: 幻耶    时间: 2011-8-24 10:22
标题: 请教小改一下状态条
如果我想把状态条改短为原来的70%,Y坐标按队伍中角色的序号依次相差20的高度,应该怎么改?
  1. #==============================================================================

  2. class Window_BattleStatus < Window_Base
  3.   #--------------------------------------------------------------------------
  4.   # ● オブジェクト初期化
  5.   #--------------------------------------------------------------------------
  6.   def initialize
  7.     super(0, 240, 640, 240)
  8.     self.contents = Bitmap.new(width - 32, height - 32)
  9.     self.opacity = 0
  10.     @background_window = Window_Base.new(0, 320, 640, 160)
  11.     @background_window.opacity = 0
  12.     @menu = Sprite.new
  13.     @menu.bitmap = RPG::Cache.picture("战斗状态")
  14.     @menu.y = 320
  15.     @menu.z += 1
  16.     @level_up_flags = [false, false, false, false]
  17.     refresh
  18.   end
  19.   #--------------------------------------------------------------------------
  20.   # ● 解放
  21.   #--------------------------------------------------------------------------
  22.   def dispose
  23.     @background_window.dispose
  24.     @menu.bitmap.dispose
  25.     super
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● レベルアップフラグの設定
  29.   #     actor_index : アクターインデックス
  30.   #--------------------------------------------------------------------------
  31.   def level_up(actor_index)
  32.     @level_up_flags[actor_index] = true
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● レベルアップ表示
  36.   #--------------------------------------------------------------------------
  37.   def refresh_level_up
  38.     for i in 0...$game_party.actors.size
  39.       if @level_up_flags[i]
  40.         bitmap = RPG::Cache.picture("System/Battle-LevelUp")
  41.         src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  42.         self.contents.blt(i * 160, 0, bitmap, src_rect)
  43.       end
  44.     end
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ● リフレッシュ
  48.   #--------------------------------------------------------------------------
  49.   def refresh
  50.     self.contents.clear
  51.     @item_max = $game_party.actors.size
  52.     for i in 0...$game_party.actors.size
  53.       actor = $game_party.actors[i]
  54.       actor_x = i * 160
  55.        y = height - 200
  56.       draw_actor_hp(actor, actor_x, y + 62, 14)
  57.       draw_actor_sp(actor, actor_x, y + 90, 14)
  58.       draw_actor_hpbar(actor, actor_x + 16, y + 86)
  59.       draw_actor_spbar(actor, actor_x + 16, y + 114)
  60.       draw_actor_state(actor, actor_x, y + 132)
  61.       draw_actor_name(actor, actor_x, y + 36)
  62.     end
  63.   end
  64.   #--------------------------------------------------------------------------
  65.   # ★ HPバー の描画
  66.   #     actor : アクター
  67.   #     x     : 描画先 X 座標
  68.   #     y     : 描画先 Y 座標
  69.   #--------------------------------------------------------------------------
  70.   def draw_actor_hpbar(actor, x, y)
  71.     bitmap = RPG::Cache.picture("空槽")
  72.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  73.     self.contents.blt(x, y, bitmap, src_rect)
  74.     bitmap = RPG::Cache.picture("血槽")
  75.     cx = actor.hp * 100 / actor.maxhp
  76.     src_rect = Rect.new(0, 0, cx, bitmap.height)
  77.     self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ★ SPバー の描画
  81.   #     actor : アクター
  82.   #     x     : 描画先 X 座標
  83.   #     y     : 描画先 Y 座標
  84.   #--------------------------------------------------------------------------
  85.   def draw_actor_spbar(actor, x, y)
  86.     bitmap = RPG::Cache.picture("空槽")
  87.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  88.     self.contents.blt(x, y, bitmap, src_rect)
  89.     bitmap = RPG::Cache.picture("气槽")
  90.     cx = actor.sp * 100 / actor.maxsp
  91.     src_rect = Rect.new(0, 0, cx, bitmap.height)
  92.     self.contents.blt(x + 103 - cx, y + 2, bitmap, src_rect)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● HP の描画
  96.   #     actor : アクター
  97.   #     x     : 描画先 X 座標
  98.   #     y     : 描画先 Y 座標
  99.   #--------------------------------------------------------------------------
  100.   def draw_actor_hp(actor, x, y, size = 16)
  101.     bitmap = RPG::Cache.picture("HP字样")
  102.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  103.     self.contents.blt(x, y + 4, bitmap, src_rect)
  104.     # HP を描画
  105.     x += 32
  106.     self.contents.font.size = size
  107.     self.contents.font.italic = true
  108.     color = actor.hp == 0 ? knockout_color :
  109.       actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  110.     draw_text_custom(x, y, 42, 32, actor.hp.to_s, color, 2)
  111.     self.contents.font.italic = false
  112.     draw_text_normal(x + 42, y, 16, 32, "/", 1)
  113.     self.contents.font.italic = true
  114.     # MaxHP を描画
  115.     draw_text_normal(x + 54, y, 42, 32, actor.maxhp.to_s, 2)
  116.     self.contents.font.italic = false
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● SP の描画
  120.   #     actor : アクター
  121.   #     x     : 描画先 X 座標
  122.   #     y     : 描画先 Y 座標
  123.   #--------------------------------------------------------------------------
  124.   def draw_actor_sp(actor, x, y, size = 16)
  125.     bitmap = RPG::Cache.picture("MP字样")
  126.     src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)
  127.     self.contents.blt(x, y + 4, bitmap, src_rect)
  128.     # SP を描画
  129.     x += 32
  130.     self.contents.font.size = size
  131.     self.contents.font.italic = true
  132.     color = actor.sp == 0 ? knockout_color :
  133.       actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  134.     draw_text_custom(x, y, 42, 32, actor.sp.to_s, color, 2)
  135.     self.contents.font.italic = false
  136.     draw_text_normal(x + 42, y, 16, 32, "/", 1)
  137.     self.contents.font.italic = true
  138.     # MaxSP を描画
  139.     draw_text_normal(x + 54, y, 42, 32, actor.maxsp.to_s, 2)
  140.     self.contents.font.italic = false
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ★ 文字列(影つき:通常色・無効色あり)の描画
  144.   #--------------------------------------------------------------------------
  145.   def draw_text_custom(x, y, width, height, str, color, align = 0)
  146.     self.contents.font.color = Color.new(36, 24, 16, 224)
  147.     self.contents.draw_text(x + 1, y + 1, width, height, str, align)
  148.     self.contents.font.color = color
  149.     self.contents.draw_text(x, y, width, height, str, align)
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ★ 文字列(影つき:通常色)の描画
  153.   #--------------------------------------------------------------------------
  154.   def draw_text_normal(x, y, width, height, str, align = 0)
  155.     self.contents.font.color = Color.new(36, 24, 16, 224)
  156.     self.contents.draw_text(x + 1, y + 1, width, height, str, align)
  157.     self.contents.font.color = normal_color
  158.     self.contents.draw_text(x, y, width, height, str, align)
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ● フレーム更新
  162.   #--------------------------------------------------------------------------
  163.   def update
  164.     super
  165.     # メインフェーズのときは不透明度をやや下げる
  166.     if $game_temp.battle_main_phase
  167.       self.contents_opacity -= 4 if self.contents_opacity > 192
  168.       self.z = 50
  169.     else
  170.       self.contents_opacity += 4 if self.contents_opacity < 255
  171.       self.z = 200
  172.     end
  173.   end
  174. end
复制代码
dsu_plus_rewardpost_czw
作者: f26401004    时间: 2011-8-24 11:18


#==============================================================================

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 = [false, false, false, false]
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    @background_window.dispose
    @menu.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● レベルアップフラグの設定
  #     actor_index : アクターインデックス
  #--------------------------------------------------------------------------
  def level_up(actor_index)
    @level_up_flags[actor_index] = 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
       y = i * 20
      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 ,  84)
      draw_actor_spbar(actor, actor_x + 16, y + 114 , 84)
      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



紅色部分是以更改過的部分,
若有什麼問題在說。(閃
作者: 幻耶    时间: 2011-8-24 13:16
f26401004 发表于 2011-8-24 11:18


#==============================================================================

下面这两句改了以后进入战斗出错:该行发生了ArgumentError,wrong number of arguments(4 for 3)
      draw_actor_hpbar(actor, actor_x + 16, y + 86 ,  84)
      draw_actor_spbar(actor, actor_x + 16, y + 114 , 84)

另外 y = i * 20 出来的效果是1号角色的状态条比2号角色的位置高,我希望的是编号大的角色状态条位置更高
作者: f26401004    时间: 2011-8-24 13:29
幻耶 发表于 2011-8-24 13:16
下面这两句改了以后进入战斗出错:该行发生了ArgumentError,wrong number of arguments(4 for 3)
     ...

      draw_actor_hpbar(actor, actor_x + 16, y + 86 ,  84)
      draw_actor_spbar(actor, actor_x + 16, y + 114 , 84)
實質上我根本不知道ls用了什麼描繪血條的腳本,
不如把那血條腳本發上來好做修改。

呃......至於另一個問題其實很簡單的.......把20改成-20即可..........|||
作者: 幻耶    时间: 2011-8-24 13:37
是一个用图片代替血槽的脚本,我改成了斜向战斗,所以觉得原来的血条太长了些,如果只把图片改短似乎显示会出问题,工程在这里,


幻耶于2011-8-24 15:59补充以下内容:
我改过图片,把图片文件改短了,但是只改图片的话显示会出错,血条在减少的时候会移到空槽外面去!应该在脚本里也要改,不知道要改哪里

ASTORY战斗.rar

265.69 KB, 下载次数: 23






欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1