标题: 在Window_EquipItem中,为什么要添加nil? [打印本页] 作者: kvkv97 时间: 2026-3-28 22:42 标题: 在Window_EquipItem中,为什么要添加nil? #--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# 添加可以装备的武器
if @equip_type == 0
weapon_set = $data_classes[@actor.class_id].weapon_set
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
@data.push($data_weapons[i])
end
end
end
# 添加可以装备的防具
if @equip_type != 0
armor_set = $data_classes[@actor.class_id].armor_set
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0 and armor_set.include?(i)
if $data_armors[i].kind == @equip_type-1
@data.push($data_armors[i])
end
end
end
end
# 添加空白 #(@item_max + @column_max - 1) / @column_max
# @data.push(nil)
# 生成位图、描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max-1
draw_item(i)
end
end
end
把 @data.push(nil)注释掉,再加判断@item_max > 0,为什么装备物品栏中没数据了?作者: 百里_飞柳 时间: 2026-3-28 23:01
因为要允许装备可以直接卸下,装备槽变成空的
但这个物品列表的设计是必须选择一个装备,才能与装备槽中的装备交换
因此增加了一个nil,专门用来让装备槽变成空的,然后装备也卸下了