Project1
标题:
经验条刷新问题
[打印本页]
作者:
黑米馒头
时间:
2014-8-2 08:40
标题:
经验条刷新问题
我在脚本里加入经验调脚本,可是切换人物的时候,经验条不刷新是怎么回事? 加入脚本为54-86行
#==============================================================================
# ■ JD_DL
#------------------------------------------------------------------------------
# 显示加点状态窗口。
#==============================================================================
class JD_DL < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize(actor)
#=================显示图片===========
@back = Sprite.new
@back.bitmap = RPG::Cache.picture("图片显示/人物属性(新)")
#=================释放图片===========
def dispose
@back.dispose
super
end
#====================================
super(320, 0, 330, 360)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 16
@actor = actor
# ** 文字高
# ** 可以放在refresh里 实时控制
@sh = 32
self.opacity = 0
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
draw_actor_face_lvup(@actor, x, y)
draw_actor_name_lvup(@actor, 113+10, 25)
draw_actor_class_lvup(@actor, 113+10, 53)
draw_actor_level_lvup(@actor, 113+10, 81)
draw_actor_hp_lvup(@actor,15+10, 144)
draw_actor_sp_lvup(@actor, 15+10, 144+28)
draw_actor_lvup(@actor, 40-155+10, 144+28*2, 0)
draw_actor_lvup(@actor, 40-155+10, 144+28*3, 2)
draw_actor_parameter(@actor, -40, 297, 1)
draw_actor_exp_lvup(@actor, 15, 254)
draw_actor_lvup(@actor,-168-15, 101+8, 4)
# ** 潜力描绘
self.contents.font.color = system_color
str = ""#潜力"
cx = sw(str)
self.contents.font.color = normal_color
self.contents.draw_text(44, 325, 300, 32, @actor.exp_s + "/" + @actor.next_exp_s)
#===============经验条显示==============================================
@exp_b = nil
@exp_c = nil
@exp_b = Sprite.new
@exp_c = Sprite.new
#=================图片显示============
@exp_b.bitmap = Bitmap.new(168,10) #(经验条1宽度,第高度)
@exp_c.bitmap = Bitmap.new(168,5) #(经验条2宽度,第高度)
#=================经验条颜色============
color2 = Color.new(111,172,115,255) #经验条1颜色
color3 = Color.new(49,159,51,255) #经验条2颜色
#=================经验值增幅度===============
@exp_d = 168*@actor.exp/@actor.next_exp_s.to_i
#=================经验条增幅条1==============
@exp_b.x = 61+310
@exp_b.y = 250+50-1
@exp_b.z = 10001
@exp_b.bitmap.fill_rect(0,0,@exp_d,32,color2)
#=================经验条增幅条2==============
@exp_c.x = 61+310
@exp_c.y = 253+50-1
@exp_c.z = 10001
@exp_c.bitmap.fill_rect(0,0,@exp_d,32,color3)
end
#===================释放经验条====================
def dispose
super
@exp_b.bitmap.dispose
@exp_c.bitmap.dispose
@exp_b.dispose
@exp_c.dispose
@exp_b = nil
@exp_c = nil
#=====================================================================
end
#=======================================================================
# ** 属性描绘
#=======================================================================
# ** 返回字符串的宽度
def sw(s)
return self.contents.text_size(s).width
end
# ** HP AND SP 描绘
def draw_v(x, y, type)
case type
when 0
word = $data_system.words.hp
dl = @actor.hp
max = @actor.maxhp
temp = $temp_hp
when 1
word = $data_system.words.sp
dl = @actor.sp
max = @actor.maxsp
temp = $temp_sp
else
return
end
self.contents.font.color = system_color
# ** 用语
str = word
self.contents.draw_text(x, y, sw(str), @sh, str)
self.contents.font.color = normal_color
# ** 基本值
cx = sw(str)
str = dl.to_s + "/"
self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
cx += sw(str)
# ** 调整颜色
if temp > 0
self.contents.font.color = text_color(6)
else
self.contents.font.color = normal_color
end
# ** 基本值 max
str = (max + temp).to_s
self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
cx += sw(str)
# ** 附加值
if temp > 0
self.contents.font.color.set(255, 100, 100)
str = "(+" + temp.to_s + ")"
self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
end
end
# ** 属性 描绘
def draw_dl(x, y, type)
# ** 准备描绘
case type
when 0
word = $data_system.words.str
dl = @actor.str
plus = $temp_str
else
return
end
# ** 开始描绘
self.contents.font.color = system_color
# ** 用语
str = word
self.contents.draw_text(x, y, sw(str), @sh, str)
# ** 设置新值颜色
if plus > 0
self.contents.font.color = text_color(6)
else
self.contents.font.color = normal_color
end
# ** 基本值
cx = sw(str)
str = (dl + plus).to_s
self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
cx += sw(str)
# ** 附加值
if plus > 0
self.contents.font.color.set(255, 100, 100)
str = "(+" + plus.to_s + ")"
self.contents.draw_text(x + cx + 10, y, sw(str), @sh, str)
end
end
end
复制代码
作者:
恐惧剑刃
时间:
2014-8-2 08:49
可能是因为没有refresh,dispose放在initialize里是失误么??
作者:
黑米馒头
时间:
2014-8-2 09:18
恐惧剑刃 发表于 2014-8-2 08:49
可能是因为没有refresh,dispose放在initialize里是失误么??
可以了。谢谢
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1