Project1
标题:
关于地图右侧状态栏无法及时刷新的问题
[打印本页]
作者:
贝多芬背多分
时间:
2012-8-28 16:40
标题:
关于地图右侧状态栏无法及时刷新的问题
本帖最后由 贝多芬背多分 于 2012-8-28 20:55 编辑
我有个小游戏,mp = hp/10 ,数值在状态栏(地图右侧)显示。但是当hp减少(400→300)时,状态栏显示的mp并没有减少,改变楼层mp减少
如果我想启动
Window_PlayerInfo(负责状态栏刷新的脚本)
那么应该怎么启动这个脚本,或者刷新地图?
作者:
贝多芬背多分
时间:
2012-8-28 16:45
#==============================================================================
# ■ Window_PlayerInfo
#------------------------------------------------------------------------------
# 地图侧面为方便查看而设立的状态窗口。
#==============================================================================
class Window_PlayerInfo < Window_Base
WLH = 14
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x,y)
super(x, y, 192, 480)
self.opacity = 0
self.z = 200
self.contents.font.size = 14
end
#--------------------------------------------------------------------------
# ● 配置
# actor : 角色
#--------------------------------------------------------------------------
def setup(actor)
@actor = actor
@hp = @actor.hp
@pow = @actor.mp
@atk = @actor.atk
@def = @actor.def
@spi = @actor.spi
@agi = @actor.agi
@lvl = @actor.level
@score = $game_scoretable.get_score
@k1 = $game_party.item_number($data_items[12])
@k2 = $game_party.item_number($data_items[13])
@k3 = $game_party.item_number($data_items[14])
@k4 = $game_party.item_number($data_items[15])
@k5 = $game_party.item_number($data_items[5])
@floor = $game_variables[2]
#@place = $game_variables[3]
@k6 = $game_variables[47]
@gold = $game_party.gold
@exp = @actor.exp
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
hs=$game_scoretable.get_hi_score($game_system.difficulty,$game_system.player)
s=$game_scoretable.get_score
hs=s if s > hs
draw_parameter(0,16,"HiScore",hs.to_s)
draw_parameter(0,16 + WLH,"Score",s.to_s)
draw_actor_name(@actor, 96, 56)
draw_actor_class(@actor, 96, WLH + 56)
draw_actor_face(@actor, 0, 64, 64)
draw_basic_info(0, 96)
draw_parameters(0, 96 + WLH*5)
draw_data(0, 96 + WLH*10)
@hp = @actor.hp
@pow = @actor.mp
@atk = @actor.atk
@def = @actor.def
@spi = @actor.spi
@agi = @actor.agi
@lvl = @actor.level
@score = $game_scoretable.get_score
@k1 = $game_party.item_number($data_items[12])
@k2 = $game_party.item_number($data_items[13])
@k3 = $game_party.item_number($data_items[14])
@k4 = $game_party.item_number($data_items[15])
@k5 = $game_party.item_number($data_items[5])
@k6 = $game_variables[47]
@floor = $game_variables[2]
#@place = $game_variables[3]
@gold = $game_party.gold
@exp = @actor.exp
end
#--------------------------------------------------------------------------
# ● 描绘数值
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
#--------------------------------------------------------------------------
def draw_parameter(x,y,name,value)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 60, WLH, name)
self.contents.font.color = normal_color
self.contents.draw_text(x + 60, y, 96, WLH, value, 2)
end
#--------------------------------------------------------------------------
# ● 描绘基本信息
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
#--------------------------------------------------------------------------
def draw_basic_info(x, y)
draw_actor_level(@actor, 96-x, y + WLH * 0)
draw_actor_state(@actor, x, y + WLH * 1)
draw_actor_hp(@actor, x, y + WLH * 2, 160)
draw_actor_mp(@actor, x, y + WLH * 3, 160)
end
#--------------------------------------------------------------------------
# ● 描绘能力值
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
#--------------------------------------------------------------------------
def draw_parameters(x, y)
draw_actor_parameter(@actor, x, y + WLH * 0, 0)
draw_actor_parameter(@actor, x, y + WLH * 1, 1)
draw_actor_parameter(@actor, x, y + WLH * 2, 2)
draw_actor_parameter(@actor, x, y + WLH * 3, 3)
self.contents.font.color = text_color(24)
self.contents.draw_text(96, y + WLH * 0+6, 32, 14, "+"
[email protected]
_s, 0)
self.contents.font.color = normal_color
end
#--------------------------------------------------------------------------
# ● 描绘系统数据
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
#--------------------------------------------------------------------------
def draw_data(x, y)
draw_parameter(x, y + WLH * 0, "黄钥匙", $game_party.item_number($data_items[12]).to_s)
draw_parameter(x, y + WLH * 1, "蓝钥匙", $game_party.item_number($data_items[13]).to_s)
draw_parameter(x, y + WLH * 2, "红钥匙", $game_party.item_number($data_items[14]).to_s)
draw_parameter(x, y + WLH * 3, "绿钥匙", $game_party.item_number($data_items[15]).to_s)
draw_parameter(x, y + WLH * 4, "炸弹", $game_party.item_number($data_items[5]).to_s)
draw_parameter(x, y + WLH * 5, "金钱", $game_party.gold.to_s)
draw_parameter(x, y + WLH * 6, "经验", @actor.exp.to_s)
#draw_parameter(x, y + WLH * 7, "层数", $game_variables[2].to_s + "层")
#draw_parameter(x, y + WLH * 8, "地区", $game_variables[3].to_s)
if !AMTT::GAME_COMPATIBLE_MODE && AMTT::GAME_USE_POSITION_STRING
/(\d*):([\+-]?\d*)=(.*)/ =~ $data_mapname[$game_map.map_id].name
draw_parameter(x, y + WLH * 7, "位置", $3.to_s)
else
draw_parameter(x, y + WLH * 7, "层数", $game_variables[3].to_s + "塔" + $game_variables[2].to_s + "层")
end
end
#--------------------------------------------------------------------------
# ● 描绘经验值信息
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
#--------------------------------------------------------------------------
def draw_exp_info(x, y)
s1 = @actor.exp_s
s2 = @actor.next_rest_exp_s
s_next = sprintf(Vocab::ExpNext, Vocab::level)
self.contents.font.color = system_color
self.contents.draw_text(x, y + WLH * 0, 180, WLH, Vocab::ExpTotal)
self.contents.draw_text(x, y + WLH * 2, 180, WLH, s_next)
self.contents.font.color = normal_color
self.contents.draw_text(x, y + WLH * 1, 180, WLH, s1, 0)
self.contents.draw_text(x, y + WLH * 3, 180, WLH, s2, 0)
end
#--------------------------------------------------------------------------
# ● 描绘装备品
# x : 描绘目标 X 坐标
# y : 描绘目标 Y 坐标
#--------------------------------------------------------------------------
def draw_equipments(x, y)
self.contents.font.color = system_color
self.contents.draw_text(x, y, 120, WLH, Vocab::equip)
for i in 0..4
draw_item_name(@actor.equips[i], x + 16, y + WLH * (i + 1))
end
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
if self.visible
# 更新画面效果
self.contents_opacity = [self.contents_opacity + 4.25, 255.0].min
self.x += (448.0 - self.x) / 60.0
# 更新内容
refresh if need_refresh?
end
end
#--------------------------------------------------------------------------
# ● 判断是否需要重绘
#--------------------------------------------------------------------------
def need_refresh?
return true if @hp != @actor.hp
return true if @pow != @actor.mp
return true if @atk != @actor.atk
return true if @def != @actor.def
return true if @spi != @actor.spi
return true if @agi != @actor.agi
return true if @lvl != @actor.level
return true if @score != $game_scoretable.get_score
return true if @k1 != $game_party.item_number($data_items[12])
return true if @k2 != $game_party.item_number($data_items[13])
return true if @k3 != $game_party.item_number($data_items[14])
return true if @k4 != $game_party.item_number($data_items[15])
return true if @k5 != $game_party.item_number($data_items[5])
return true if @k6 != $game_variables[47]
return true if @floor != $game_variables[2]
#return true if @place != $game_variables[3]
return true if @gold != $game_party.gold
return true if @exp != @actor.exp
return false
end
end
复制代码
作者:
贝多芬背多分
时间:
2012-8-28 20:57
贝多芬背多分 发表于 2012-8-28 16:45
回复@delv25
......
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1