赞 45
VIP 0
好人卡 0
积分 146
经验 0
最后登录 2024-11-14
在线时间 2192 小时
Lv4.逐梦者
梦石 0
星屑 14581
在线时间 2192 小时
注册时间 2019-1-24
帖子 1123
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 miantouchi 于 2019-11-14 20:48 编辑
class Scene_Equip 类当中refresh 几点疑问?
看了差不多2天吧,不知道是我笨还是太难了,太绕了有点。
问题一,hp和sp好像在刷新里面根本就没用到?只用了攻击、物防、法防这三个的描绘。
last_hp = @actor.hp
last_sp = @actor.sp
@actor.hp = last_hp
@actor.sp = last_sp
问题二,
我的疑问是为什么去掉,@actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)这一句后会出现默认的数值和后面的装备后数值是一样的
我看了下Window_EquipLeft的refresh里面,
draw_actor_parameter(@actor, 4, 64, 0)#描绘能力值0,1,2 攻击、防御、魔法
draw_actor_parameter(@actor, 4, 96, 1)
draw_actor_parameter(@actor, 4, 128, 2)
应该是这三句话描绘的装备前的数值,
我注释掉的这句话是如何影响到的?
以下是分别两个类的源码
#==============================================================================
# ■ Scene_Equip
#------------------------------------------------------------------------------
# 处理装备画面的类。
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 设置物品窗口的可视状态
@item_window1 .visible = ( @right_window.index == 0 )
@item_window2 .visible = ( @right_window.index == 1 )
@item_window3 .visible = ( @right_window.index == 2 )
@item_window4 .visible = ( @right_window.index == 3 )
@item_window5 .visible = ( @right_window.index == 4 )
# 获取当前装备中的物品
item1 = @right_window .item
# 设置当前的物品窗口到 @item_window
case @right_window .index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# 右窗口被激活的情况下
if @right_window .active
# 删除变更装备后的能力
@left_window .set_new_parameters ( nil , nil , nil )
end
# 物品窗口被激活的情况下
if @item_window .active
# 获取现在选中的物品
item2 = @item_window .item
# 变更装备
last_hp = @actor .hp
last_sp = @actor .sp
@actor .equip ( @right_window.index , item2 == nil ? 0 : item2.id )
# 获取变更装备后的能力值
new_atk = @actor .atk
new_pdef = @actor .pdef
new_mdef = @actor .mdef
# 返回到装备
@actor .equip ( @right_window.index , item1 == nil ? 0 : item1.id )
@actor .hp = last_hp
@actor .sp = last_sp
# 描画左窗口
@left_window .set_new_parameters ( new_atk, new_pdef, new_mdef)
end
end
end
#==============================================================================
# ■ Scene_Equip
#------------------------------------------------------------------------------
# 处理装备画面的类。
#==============================================================================
class Scene_Equip
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
# 设置物品窗口的可视状态
@item_window1 .visible = ( @right_window.index == 0 )
@item_window2 .visible = ( @right_window.index == 1 )
@item_window3 .visible = ( @right_window.index == 2 )
@item_window4 .visible = ( @right_window.index == 3 )
@item_window5 .visible = ( @right_window.index == 4 )
# 获取当前装备中的物品
item1 = @right_window .item
# 设置当前的物品窗口到 @item_window
case @right_window .index
when 0
@item_window = @item_window1
when 1
@item_window = @item_window2
when 2
@item_window = @item_window3
when 3
@item_window = @item_window4
when 4
@item_window = @item_window5
end
# 右窗口被激活的情况下
if @right_window .active
# 删除变更装备后的能力
@left_window .set_new_parameters ( nil , nil , nil )
end
# 物品窗口被激活的情况下
if @item_window .active
# 获取现在选中的物品
item2 = @item_window .item
# 变更装备
last_hp = @actor .hp
last_sp = @actor .sp
@actor .equip ( @right_window.index , item2 == nil ? 0 : item2.id )
# 获取变更装备后的能力值
new_atk = @actor .atk
new_pdef = @actor .pdef
new_mdef = @actor .mdef
# 返回到装备
@actor .equip ( @right_window.index , item1 == nil ? 0 : item1.id )
@actor .hp = last_hp
@actor .sp = last_sp
# 描画左窗口
@left_window .set_new_parameters ( new_atk, new_pdef, new_mdef)
end
end
end
#==============================================================================
# ■ Window_EquipLeft
#------------------------------------------------------------------------------
# 装备画面的、显示角色能力值变化的窗口。
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize( actor)
super ( 0 , 64 , 272 , 192 )
self .contents = Bitmap.new ( width - 32 , height - 32 )
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self .contents .clear
draw_actor_name( @actor, 4 , 0 ) #描绘姓名 X、Y坐标
draw_actor_level( @actor, 4 , 32 )
draw_actor_parameter( @actor, 4 , 64 , 0 ) #描绘能力值0,1,2 攻击、防御、魔法
draw_actor_parameter( @actor, 4 , 96 , 1 )
draw_actor_parameter( @actor, 4 , 128 , 2 )
#p @new_atk
if @new_atk != nil
self .contents .font .color = system_color
self .contents .draw_text ( 160 , 64 , 40 , 32 , "→" , 1 )
self .contents .font .color = normal_color
self .contents .draw_text ( 200 , 64 , 36 , 32 , @new_atk .to_s , 2 )
end
if @new_pdef != nil
self .contents .font .color = system_color
self .contents .draw_text ( 160 , 96 , 40 , 32 , "→" , 1 )
self .contents .font .color = normal_color
self .contents .draw_text ( 200 , 96 , 36 , 32 , @new_pdef .to_s , 2 )
end
if @new_mdef != nil
self .contents .font .color = system_color
self .contents .draw_text ( 160 , 128 , 40 , 32 , "→" , 1 )
self .contents .font .color = normal_color
self .contents .draw_text ( 200 , 128 , 36 , 32 , @new_mdef .to_s , 2 )
end
end
#--------------------------------------------------------------------------
# ● 变更装备后的能力值设置
# new_atk : 变更装备后的攻击力
# new_pdef : 变更装备后的物理防御
# new_mdef : 变更装备后的魔法防御
#--------------------------------------------------------------------------
def set_new_parameters( new_atk, new_pdef, new_mdef)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
refresh
end
end
end
#==============================================================================
# ■ Window_EquipLeft
#------------------------------------------------------------------------------
# 装备画面的、显示角色能力值变化的窗口。
#==============================================================================
class Window_EquipLeft < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# actor : 角色
#--------------------------------------------------------------------------
def initialize( actor)
super ( 0 , 64 , 272 , 192 )
self .contents = Bitmap.new ( width - 32 , height - 32 )
@actor = actor
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self .contents .clear
draw_actor_name( @actor, 4 , 0 ) #描绘姓名 X、Y坐标
draw_actor_level( @actor, 4 , 32 )
draw_actor_parameter( @actor, 4 , 64 , 0 ) #描绘能力值0,1,2 攻击、防御、魔法
draw_actor_parameter( @actor, 4 , 96 , 1 )
draw_actor_parameter( @actor, 4 , 128 , 2 )
#p @new_atk
if @new_atk != nil
self .contents .font .color = system_color
self .contents .draw_text ( 160 , 64 , 40 , 32 , "→" , 1 )
self .contents .font .color = normal_color
self .contents .draw_text ( 200 , 64 , 36 , 32 , @new_atk .to_s , 2 )
end
if @new_pdef != nil
self .contents .font .color = system_color
self .contents .draw_text ( 160 , 96 , 40 , 32 , "→" , 1 )
self .contents .font .color = normal_color
self .contents .draw_text ( 200 , 96 , 36 , 32 , @new_pdef .to_s , 2 )
end
if @new_mdef != nil
self .contents .font .color = system_color
self .contents .draw_text ( 160 , 128 , 40 , 32 , "→" , 1 )
self .contents .font .color = normal_color
self .contents .draw_text ( 200 , 128 , 36 , 32 , @new_mdef .to_s , 2 )
end
end
#--------------------------------------------------------------------------
# ● 变更装备后的能力值设置
# new_atk : 变更装备后的攻击力
# new_pdef : 变更装备后的物理防御
# new_mdef : 变更装备后的魔法防御
#--------------------------------------------------------------------------
def set_new_parameters( new_atk, new_pdef, new_mdef)
if @new_atk != new_atk or @new_pdef != new_pdef or @new_mdef != new_mdef
@new_atk = new_atk
@new_pdef = new_pdef
@new_mdef = new_mdef
refresh
end
end
end