Project1

标题: 显示多个状态图标 [打印本页]

作者: fjm    时间: 2017-4-1 14:56
标题: 显示多个状态图标
本帖最后由 fjm 于 2017-4-1 18:55 编辑

默认的是两个,如何多显示几个,比如4个

RUBY 代码复制
  1. class Scene_Battle < Scene_Base
  2.     def start
  3.     super
  4.     create_spriteset
  5.     create_all_windows
  6.     BattleManager.method_wait_for_message = method(:wait_for_message)
  7.     @icon_rotate = 0
  8.   end
  9.     def update_basic
  10.     super
  11.     $game_timer.update
  12.     $game_troop.update
  13.     @spriteset.update
  14.     update_info_viewport
  15.     update_message_open
  16.     @icon_rotate += 1
  17.     if @icon_rotate > 120
  18.       $game_party.alive_members.each{|i| i.sort_states}
  19.       @status_window.refresh
  20.       @icon_rotate = 0
  21.     end
  22.   end
  23.     def update_info_viewport
  24.     move_info_viewport(0)   if @party_command_window.active
  25.     move_info_viewport(0) if @actor_command_window.active
  26.     move_info_viewport(0)  if BattleManager.in_turn?
  27.   end
  28.   def create_party_command_window
  29.     @party_command_window = Window_PartyCommand.new
  30.     @party_command_window.y = @info_viewport.rect.y - @party_command_window.height
  31.     @party_command_window.set_handler(:fight,  method(:command_fight))
  32.     @party_command_window.set_handler(:escape, method(:command_escape))
  33.     @party_command_window.unselect
  34.   end
  35.     def create_status_window
  36.     @status_window = Window_BattleStatus.new
  37.   end
  38.     def create_actor_command_window
  39.     @actor_command_window = Window_ActorCommand.new
  40.     @actor_command_window.y = @info_viewport.rect.y - @actor_command_window.height
  41.     #@actor_command_window.x = Graphics.width - @actor_command_window.width
  42.     @actor_command_window.set_handler(:attack, method(:command_attack))
  43.     @actor_command_window.set_handler(:skill,  method(:command_skill))
  44.     @actor_command_window.set_handler(:guard,  method(:command_guard))
  45.     @actor_command_window.set_handler(:item,   method(:command_item))
  46.     @actor_command_window.set_handler(:cancel, method(:prior_command))
  47.   end
  48. end
  49. class Window_BattleEnemy < Window_Selectable
  50.     def initialize(info_viewport)
  51.     super(0, info_viewport.rect.y, window_width, fitting_height(6))
  52.     refresh
  53.     self.visible = false
  54.     @info_viewport = info_viewport
  55.   end
  56.   def window_width
  57.     Graphics.width
  58.   end
  59. end
  60. class Window_PartyCommand < Window_Command
  61.   def window_width
  62.     return 100
  63.   end
  64.     def visible_line_number
  65.     return 3
  66.   end
  67.     def alignment
  68.     return 1
  69.   end
  70. end
  71. class Window_BattleStatus < Window_Selectable
  72.   def window_width
  73.     Graphics.width
  74.   end
  75.     def col_max
  76.     return 2
  77.   end
  78.     def draw_actor_icons(actor, x, y, width = 96)
  79.     icons = (actor.state_icons + actor.buff_icons)[0, width / 24]
  80.     icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
  81.   end
  82.     def draw_basic_area(rect, actor)
  83.     draw_actor_name(actor, rect.x - 7, rect.y, 100)
  84.     draw_actor_icons(actor, rect.x + 59 , rect.y, 24)
  85.   end
  86.   def spacing
  87.     return 4
  88.   end
  89.   def draw_actor_hp(actor, x, y, width = 124)
  90.     draw_gauge(x+60, y, width-15, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  91.     change_color(system_color)
  92.     draw_text(x+55, y, 30, line_height, Vocab::hp_a)
  93.     draw_current_and_max_values(x+45, y, width, actor.hp, actor.mhp,
  94.       hp_color(actor), normal_color)
  95.   end
  96.   def draw_actor_mp(actor, x, y, width = 124)
  97.     draw_gauge(x+42, y, width-15, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
  98.     change_color(system_color)
  99.     draw_text(x+38, y, 30, line_height, Vocab::mp_a)
  100.     draw_current_and_max_values(x+25, y, width, actor.mp, actor.mmp,
  101.       mp_color(actor), normal_color)
  102.   end
  103.   def draw_actor_tp(actor, x, y, width = 124)
  104.     draw_gauge(x+25, y, width-20, actor.tp_rate, tp_gauge_color1, tp_gauge_color2)
  105.     change_color(system_color)
  106.     draw_text(x+20, y, 30, line_height, Vocab::tp_a)
  107.     change_color(tp_color(actor))
  108.     draw_text(x + width - 37, y, 42, line_height, actor.tp.to_i, 2)
  109.   end
  110. end

9999.jpg (41.96 KB, 下载次数: 26)

9999.jpg

作者: 魔法丶小肉包    时间: 2017-4-1 19:21
本帖最后由 魔法丶小肉包 于 2017-4-1 19:26 编辑

由于楼主给的脚本不是默认系统,给的截图却是默认系统的,所以都改了

根据默认系统脚本修改
RUBY 代码复制
  1. class Window_BattleStatus < Window_Selectable
  2.   def draw_basic_area(rect, actor)
  3.     draw_actor_name(actor, rect.x + 0, rect.y, 100)
  4.     draw_actor_icons(actor, rect.x + 70, rect.y, rect.width)
  5.   end
  6. end

使用了楼主给的脚本之后修改
RUBY 代码复制
  1. class Window_BattleStatus < Window_Selectable
  2.   def draw_basic_area(rect, actor)
  3.     draw_actor_name(actor, rect.x - 7, rect.y, 100)
  4.     draw_actor_icons(actor, rect.x + 59 , rect.y, 24*4)
  5.   end
  6. end

作者: fjm    时间: 2017-4-1 20:22
魔法丶小肉包 发表于 2017-4-1 19:21
由于楼主给的脚本不是默认系统,给的截图却是默认系统的,所以都改了

根据默认系统脚本修改

太感谢了,非常好用
作者: vodgabongd    时间: 2021-2-25 12:31
正在找类似的功能,MV有办法在战斗时显示多个状态吗?




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