作者: 八云紫 时间: 2010-11-17 16:28
def draw_item(index)
name = ""
$data_actors.each do |actor|
name = actor.name if actor
end
rect = item_rect(index)
self.contents.clear_rect(rect)
self.contents.draw_text(rect, name)
end
我明白你的意思,你是想通过id获取对象:
for id in 1..$data_actors.size
actor = $data_actors[id]
end
而Array#each方法则是迭代数组中的每个元素。
$data_actors.each do |actor|
# 这里每次迭代的actor就等于上面actor = $data_actors[id]
end