刚刚研究了一下状态显示和实际状态更新变化不同步的问题,你看看这样改可以吗
#============================================================================== # ■ Window_BattleStatus #------------------------------------------------------------------------------ # 显示战斗画面同伴状态的窗口。 #============================================================================== class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 320, 640, 160) self.contents = Bitmap.new(width - 32, height - 32) @level_up_flags = [false, false, false, false] # 记录初始状态,用于后续对比 @last_states = $game_party.actors.map { |actor| actor.states.clone } refresh end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # ● 设置升级标志 # actor_index : 角色索引 #-------------------------------------------------------------------------- def level_up(actor_index) @level_up_flags[actor_index] = true end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear @item_max = $game_party.actors.size for i in 0...$game_party.actors.size actor = $game_party.actors[i] actor_x = i * 160 + 4 draw_actor_name(actor, actor_x, 0) draw_actor_hp(actor, actor_x, 32, 120) draw_actor_sp(actor, actor_x, 64, 120) if @level_up_flags[i] self.contents.font.color = normal_color self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!") else draw_actor_state(actor, actor_x, 96) end end end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update super # 检测状态变化并刷新 check_state_change # 主界面的不透明度调整 if $game_temp.battle_main_phase self.contents_opacity -= 4 if self.contents_opacity > 191 else self.contents_opacity += 4 if self.contents_opacity < 255 end end #-------------------------------------------------------------------------- # ● 检测状态变化 #-------------------------------------------------------------------------- def check_state_change # 获取当前所有角色的状态 current_states = $game_party.actors.map { |actor| actor.states.clone } # 对比上一帧状态,不同则刷新 if @last_states != current_states refresh @last_states = current_states.clone end end end
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
# 显示战斗画面同伴状态的窗口。
#==============================================================================
class Window_BattleStatus < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 320, 640, 160)
self.contents = Bitmap.new(width - 32, height - 32)
@level_up_flags = [false, false, false, false]
# 记录初始状态,用于后续对比
@last_states = $game_party.actors.map { |actor| actor.states.clone }
refresh
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
super
end
#--------------------------------------------------------------------------
# ● 设置升级标志
# actor_index : 角色索引
#--------------------------------------------------------------------------
def level_up(actor_index)
@level_up_flags[actor_index] = true
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
@item_max = $game_party.actors.size
for i in 0...$game_party.actors.size
actor = $game_party.actors[i]
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
draw_actor_hp(actor, actor_x, 32, 120)
draw_actor_sp(actor, actor_x, 64, 120)
if @level_up_flags[i]
self.contents.font.color = normal_color
self.contents.draw_text(actor_x, 96, 120, 32, "LEVEL UP!")
else
draw_actor_state(actor, actor_x, 96)
end
end
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 检测状态变化并刷新
check_state_change
# 主界面的不透明度调整
if $game_temp.battle_main_phase
self.contents_opacity -= 4 if self.contents_opacity > 191
else
self.contents_opacity += 4 if self.contents_opacity < 255
end
end
#--------------------------------------------------------------------------
# ● 检测状态变化
#--------------------------------------------------------------------------
def check_state_change
# 获取当前所有角色的状态
current_states = $game_party.actors.map { |actor| actor.states.clone }
# 对比上一帧状态,不同则刷新
if @last_states != current_states
refresh
@last_states = current_states.clone
end
end
end
|