设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: tree52
打印 上一主题 下一主题

[已经解决] 脚本中Game_Actor的一个问题

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
61
在线时间
24 小时
注册时间
2008-8-5
帖子
1924
11
发表于 2009-8-10 20:47:22 | 只看该作者
其实楼上几位提到的分歧法效率是最高的,但是那样写的话代码会变得比较冗长,n*(4-$game_party.actors.size) 的话就比较简洁~

你找到血条脚本中的两段 case...end,在后面对 x 和 y 做相同的加减运算:
x += 32 * (4 - $game_party.actors.size)
y -= 32 * (4 - $game_party.actors.size)
即可~

点评

嘿··· 我翻到1年前苏苏帮我的,那时候我才刚开始接触RM呢。对了,发你的脚本里面如果用查找“紫苏”的话,可以找到你呢,嘿嘿~~~  发表于 2010-8-22 01:15
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
120
在线时间
92 小时
注册时间
2009-8-1
帖子
438
12
 楼主| 发表于 2009-8-10 22:12:24 | 只看该作者
11# 紫苏


谢谢紫苏,处理好咯。献上处理好的HP、MP脚本:
  1. # 感谢 传说中di 提供脚本,感谢 紫苏 修改脚本
  2. #==============================================================================
  3. # ■ Window_Base
  4. #------------------------------------------------------------------------------
  5. #  游戏中全部窗口的超级类。
  6. #==============================================================================

  7. class Window_Base < Window
  8. #--------------------------------------------------------------------------
  9. # ● 描绘 HP
  10. #     actor : 角色
  11. #     x     : 描画目标 X 坐标
  12. #     y     : 描画目标 Y 坐标
  13. #     width : 描画目标的宽
  14. #--------------------------------------------------------------------------
  15. def draw_actor_hp1(actor, x, y, width = 72)
  16.    # 描绘字符串 "HP"
  17.    self.contents.font.color = system_color
  18.    self.contents.draw_text(x, y, 24, 24, $data_system.words.hp)
  19.    # 计算描绘 MaxHP 所需的空间
  20.    if width - 24 >= 32
  21.      hp_x = x + 32# + width - 24
  22.    end
  23.    # 描绘 HP
  24.    self.contents.font.color = actor.hp == 0 ? knockout_color :
  25.      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
  26.    self.contents.draw_text(hp_x, y, 32, 24, actor.hp.to_s, 2)
  27. end
  28. #--------------------------------------------------------------------------
  29. # ● 描绘 SP
  30. #     actor : 角色
  31. #     x     : 描画目标 X 坐标
  32. #     y     : 描画目标 Y 坐标
  33. #     width : 描画目标的宽
  34. #--------------------------------------------------------------------------
  35. def draw_actor_sp1(actor, x, y, width = 72)
  36.    # 描绘字符串 "SP"
  37.    self.contents.font.color = system_color
  38.    self.contents.draw_text(x, y, 24, 24, $data_system.words.sp)
  39.    # 计算描绘 MaxSP 所需的空间
  40.    if width - 24 >= 32
  41.      sp_x = x + 32# + width - 24
  42.    end
  43.    # 描绘 SP
  44.    self.contents.font.color = actor.sp == 0 ? knockout_color :
  45.      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
  46.    self.contents.draw_text(sp_x, y, 32, 24, actor.sp.to_s, 2)
  47. end
  48. end





  49. #==============================================================================
  50. # ■ Window_BattleStatus
  51. #------------------------------------------------------------------------------
  52. #  显示战斗画面同伴状态的窗口。
  53. #==============================================================================

  54. class Window_BattleStatus < Window_Base
  55. #--------------------------------------------------------------------------
  56. # ● 初始化对像
  57. #--------------------------------------------------------------------------
  58. #$data_system_level_up_me = "Audio/ME/升级音乐"
  59. def initialize
  60.    super(0, 0, 640, 480)
  61.    self.contents = Bitmap.new(width - 10, height - 32)
  62.    self.opacity = 0
  63.    @level_up_flags = [false, false, false, false]
  64.    refresh
  65. end
  66. #--------------------------------------------------------------------------
  67. # ● 释放
  68. #--------------------------------------------------------------------------
  69. def dispose
  70.    super
  71. end
  72. #--------------------------------------------------------------------------
  73. # ● 设置升级标志
  74. #     actor_index : 角色索引
  75. #--------------------------------------------------------------------------
  76. def level_up(actor_index)
  77.    @level_up_flags[actor_index] = true
  78. end
  79. #--------------------------------------------------------------------------
  80. # ● 刷新
  81. #--------------------------------------------------------------------------
  82. def refresh
  83.    self.contents.clear
  84.    @item_max = $game_party.actors.size
  85.     for i in 0...$game_party.actors.size
  86.      actor = $game_party.actors[i]
  87.      case i
  88.        when 0
  89.         x = 310
  90.         y = 390
  91.        when 1
  92.         x = 390
  93.         y = 340
  94.        when 2
  95.         x = 480
  96.         y = 300
  97.        when 3
  98.         x = 550
  99.         y = 270
  100.       end
  101.       x+= 32 * (4 - $game_party.actors.size)
  102.       y-= 32 * (4 - $game_party.actors.size)
  103.       
  104.      if @level_up_flags[i]
  105.        self.contents.font.color = normal_color
  106.        self.contents.draw_text(x, y, 80, 24, "LEVEL UP!")
  107.        Audio.me_stop
  108. #        Audio.me_play($data_system_level_up_me)
  109.      else
  110.      draw_actor_hp1(actor, x-15, y-15, 80)
  111.      draw_actor_sp1(actor, x-15, y+5, 80)
  112.     end
  113.    end
  114. end

  115. #--------------------------------------------------------------------------
  116.   # ● 刷新画面
  117.   #--------------------------------------------------------------------------
  118.   def update
  119.     super
  120.     # 主界面的不透明度下降
  121.     if $game_temp.battle_main_phase
  122.       self.contents_opacity -= 4 if self.contents_opacity > 191
  123.     else
  124.       self.contents_opacity += 4 if self.contents_opacity < 255
  125.     end
  126.   end
  127. end





  128. #==============================================================================
  129. # ■ Window_BattleStatus
  130. #==============================================================================
  131. class Window_BattleStatus < Window_Base
  132. #--------------------------------------------------------------------------
  133. # ● 初始化
  134. #--------------------------------------------------------------------------
  135. alias xrxs_bp2_refresh refresh
  136. def refresh
  137.    xrxs_bp2_refresh
  138.    @item_max = $game_party.actors.size
  139.     for i in 0...$game_party.actors.size
  140.      actor = $game_party.actors[i]
  141.      case i
  142.        when 0
  143.         x = 310
  144.         y = 390
  145.        when 1
  146.         x = 390
  147.         y = 340
  148.        when 2
  149.         x = 480
  150.         y = 300
  151.        when 3
  152.         x = 550
  153.         y = 270
  154.       end
  155.       x+= 32 * (4 - $game_party.actors.size)
  156.       y-= 32 * (4 - $game_party.actors.size)
  157.       
  158.      draw_actor_hp_meter(actor, x, y, 50)
  159.      draw_actor_sp_meter(actor, x, y + 8, 50)
  160.    end
  161. end
  162. end
  163. #==============================================================================
  164. # ■ Window_Base
  165. #==============================================================================
  166. class Window_Base < Window
  167. #--------------------------------------------------------------------------
  168. # ● HP描画
  169. #--------------------------------------------------------------------------
  170. def draw_actor_hp_meter(actor, x, y, width = 156, type = 0)
  171.    if type == 1 and actor.hp == 0
  172.      return
  173.    end
  174.    self.contents.font.color = system_color
  175.    self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 25))
  176.    w = width * actor.hp / actor.maxhp
  177.    self.contents.fill_rect(x, y+28, w,1, Color.new(255, 96, 96, 255))
  178.    self.contents.fill_rect(x, y+29, w,1, Color.new(255, 0, 0, 255))
  179.    self.contents.fill_rect(x, y+30, w,1, Color.new(128, 0, 0, 255))
  180.    self.contents.fill_rect(x, y+31, w,1, Color.new(0, 0, 0, 255))
  181.    
  182.    end
  183. #--------------------------------------------------------------------------
  184. # ● SP描画
  185. #--------------------------------------------------------------------------
  186. def draw_actor_sp_meter(actor, x, y, width = 156, type = 0)
  187.    if type == 1 and actor.hp == 0
  188.      return
  189.    end
  190.    self.contents.font.color = system_color
  191.    self.contents.fill_rect(x-1, y+27, width+2,6, Color.new(0, 0, 0, 255))
  192.    w = width * actor.sp / actor.maxsp
  193.    self.contents.fill_rect(x, y+28, w,1, Color.new(128, 255, 255, 255))
  194.    self.contents.fill_rect(x, y+29, w,1, Color.new(0, 255, 255, 255))
  195.    self.contents.fill_rect(x, y+30, w,1, Color.new(0, 192, 192, 255))
  196.    self.contents.fill_rect(x, y+31, w,1, Color.new(0, 128, 128, 255))
  197. end
  198. end
复制代码
附带一张效果图:


再次感谢你们的解答,我结贴咯……
哎呦,好像快要能发布一款游戏了,这次一定要低调!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-16 06:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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