Project1
标题:
请教个窗口问题
[打印本页]
作者:
wwwcctvty
时间:
2012-11-16 16:06
标题:
请教个窗口问题
本帖最后由 hys111111 于 2012-11-16 18:52 编辑
class Window_ComposeUp < Window_Selectable
attr_accessor :forge_item
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize(forge_item)
super(180, 90, 130, 80)
@column_max = 2
@forge_item = []
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● 获取物品
#--------------------------------------------------------------------------
def item_number
return @data_number[self.index]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
@data_number = []
@forge_item = $game_temp.forge
for item_forge in @forge_item
case item_forge[0]
when 0
item = $data_items[item_forge[1]]
when 1
item = $data_weapons[item_forge[1]]
when 2
item = $data_armors[item_forge[1]]
end
if (item != nil) and (item_forge[2] != 0)
@data.push(item)
@data_number.push(item_forge[2])
else
@data.delete(item)
end
end
# 如果项目数不是 0 就生成位图、描绘全部项目
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 55)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 描绘项目
# index : 项目标号
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_temp.forge[index][2]
when RPG::Weapon
number = $game_temp.forge[index][2]
when RPG::Armor
number = $game_temp.forge[index][2]
end
self.contents.font.color = normal_color
x = 4 + index % @column_max * (60)
y = 8
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 10, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 10, y - 15, 24, 32, number.to_s, 2)
end
复制代码
如何让这窗口中只能放二个物品而且数量为1?
请教大大们
{:2_258:} dsu_plus_rewardpost_czw
作者:
wwwcctvty
时间:
2012-11-16 20:49
那数量怎么控制呢
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1