| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2014-8-26 |
| 在线时间 | 45 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 45 小时
- 注册时间
- 2010-8-21
- 回帖
- 49
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 RyanBern 于 2014-7-20 15:11 编辑
最近在做物品分类时出现了一个问题,就是想把防具和装饰品分开,但怎么做都做不出来,大侠麻烦来帮个忙。
附脚本:- #==============================================================================
- # ■ Window_ItemTitle
- #------------------------------------------------------------------------------
- # 选择类别
- #==============================================================================
- class Window_ItemTitle < Window_Base #"使用物品"四个字的窗口
- def initialize
- super(0, 0, 160, 64)
- self.contents = Bitmap.new(width - 32, height - 32)
- self.contents.clear
- self.contents.font.color = Color.new(189, 183, 103, 200)
- self.contents.draw_text(4, 0, 120, 32, $data_system.words.item, 1)
- end
- end
- class Window_ItemCommand < Window_Selectable
-
- #———— 初始化 ————
- def initialize
- super(0, 64, 160, 352)
- self.contents = Bitmap.new(width - 32, height - 32)
- @item_max = 5
-
- @commands = [" 恢 复 用 品", " 武 器", " 防 具 辅 助", " 材 料", " 不 明 物 品"]
- refresh
- self.index = 0
- end
-
- #———— 刷新 ————
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i, normal_color)
- end
- end
- #—— 描绘项目 ——| index:编号,color:颜色——————
- def draw_item(index, color)
- self.contents.font.color = color
- y = index * 32
- self.contents.draw_text(4, y, 128, 32, @commands[index])
- end
- #—— 帮助部分更新 ————
- def update_help
- case self.index
- when 0
- @text = @commands[0]
- when 1
- @text = @commands[1]
- when 2
- @text = @commands[2]
- when 3
- @text = @commands[3]
- when 4
- @text = @commands[4]
- end
- @help_window.set_text(@text)
- end
-
- end # Window_ItemCommand的
- #==============================================================================
- # ■ Window_ItemCommand
- #------------------------------------------------------------------------------
- # 选择类别
- #==============================================================================
- #==============================================================================
- # ■ Window_ItemList
- #------------------------------------------------------------------------------
- # 物品窗口。 item.variance是物品的"分散度",借来用做分类
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #———— 初始化 ————
- def initialize
- super(160, 0, 480, 416)
- refresh
- self.index = 0
- end
- #—— 取得现在选择的物品 ——
- def item
- return @data[self.index]
- end
-
- #—— 刷新 ———
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- end
-
-
- #—— 设置不同类别的物品 ———
- def set_item(command)
- refresh
- #—— 根据现在的选项决定物品 ——
- case command
- when 0 #恢复类,分散度为0
- for i in 1...$data_items.size
- if ($data_items[i].variance == 0 and $game_party.item_number(i) > 0)
- @data.push($data_items[i])
- end
- end
- when 1 #武器类:
- for i in 1...$game_party.weapons.size
- if $game_party.weapons[i] != nil
- @data.push($game_party.weapons[i]) if ! $game_party.weapons[i].equiping
- end
- end
- when 2 #防具辅助类
- for i in 1...$game_party.armors.size
- if $game_party.armors[i] != nil
- @data.push($game_party.armors[i]) if ! $game_party.armors[i].equiping
- end
- end
- when 3 #材料
- for i in 1...$data_items.size
- if ($data_items[i].variance == 6 and $game_party.item_number(i) > 0)
- @data.push($data_items[i])
- end
- end
- when 4 #不明物品类:分散度为5
- for i in 1...$data_items.size
- if ($data_items[i].variance == 5 and $game_party.item_number(i) > 0)
- @data.push($data_items[i])
- end
- end
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #——— 单类物品的个数 ————
- def item_number
- return @item_max
- end
-
-
- #——— 项目内容的描画 ————
- def draw_item(index)
- item = @data[index]
- #—— 取得具体物品数量 ——
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
-
- #—— 给出物品的颜色 ——
- if item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = Color.new(153, 153, 153, 220)
- end
-
- #—— 描绘物体图标、物体名、数量 ——
- x = 4
- y = index * 32
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
- end
-
- #——— 更新帮助窗口 ————
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end #—— Window_ItemList 的 ——
复制代码 我试过用 .kind 进行分解,但是分解开以后不报错,分类里也显示不出任何防具和装饰品,试了好几种方法,结果都是无法显示出防具和饰品,有点晕了,求大侠出来帮忙解释下,谢谢了~~~~~~~~ |
|