幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2877|回复: 4

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

[复制链接]

40

主题

190

帖子

1635

积分

⑥精研

●~  ●~   ●

积分
1635
发表于 2011-8-24 14:26:26 | 显示全部楼层 |阅读模式
是一个用图片代替血槽的脚本,我改成了斜向战斗,所以觉得原来的血条太长了些,想把血条改短到70%并且改小两个角色血条之间的间距,如果只把图片改短似乎显示会出问题。


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

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2011-8-24 16:01:14 | 显示全部楼层
这要看你的“空槽”“血槽”的图片是什么样子的。。。怎么说呢,这个脚本不是单纯的用精灵显示血条。。。而是bitmap操作。。。这个不太好办。。XP好像不能放大缩小blt,vx才加了这个功能的。。所以呢,最简单的方法就是。。。把图片从新做一下,做成70%大小就可以了。。。。

然后是距离。。注释有drawhp 、 sp什么的就在那里。。。改一下x,y坐标就可以了。。。
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

40

主题

190

帖子

1635

积分

⑥精研

●~  ●~   ●

积分
1635
 楼主| 发表于 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
回复 支持 反对

使用道具 举报

40

主题

190

帖子

1635

积分

⑥精研

●~  ●~   ●

积分
1635
 楼主| 发表于 2011-8-24 16:12:59 | 显示全部楼层
好像这样就对了。。。
回复 支持 反对

使用道具 举报

550

主题

9116

帖子

214748万

积分

超级版主

如同神一般的存在,腿神!拖后腿的神~~

Rank: 8Rank: 8

积分
2147483647
发表于 2011-8-24 17:44:30 | 显示全部楼层
应该是这样。。具体的工程我也没有,只能提这些建议。。。
我就是你们的神,庶民们,追随我吧!跟着我一起拖后腿!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-3-29 14:35 , Processed in 0.021457 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表