如何简化在 corona 中加载一些文件?

How do I simplify to load some files in the corona?

我是新手,所有的工作都是从别人的头开始的。让我看看,我有 3 张图片,标题为 shop1price shop2price shop3price。现在我想把它简化为下面的代码

local options =
{
    { defaultFile = 'images/shop1price.png' },
    { defaultFile = 'images/shop2price.png' },
    { defaultFile = 'images/shop3price.png' },
}

local priceTag = {}
for i = 1,3 do
    priceTag[i] = widget.newButton{
        options[i],
        overColor = {128,128,128,255},
        width = 73,
        height = 38,
        left = (centerX-155) + (i-1)*118,
        top = centerY * 0.88,
        id = i,
        onEvent = function (e) 
            if e.phase == 'ended' then
                onTouchBuy(e.target.id)
            end
            return true 
        end
    }
    -- priceTag[i] : setReferencePoint( display.CenterReferencePoint )
    priceTag[i] : scale( 0.8 , 0.8 )
    buttonGroup : insert( priceTag[i] )
end

但是按钮没有出现,我认为错误在options[i]。但问题始终是我不知道如何正确。我知道我可以自己一个一个地编写代码,但这肯定很累。例如,如果我有 100 个按钮怎么办。

如有任何帮助,我们将不胜感激。

 local options = {}

  [#options+1] =   'images/shop1price.png'
  [#options+1] =   'images/shop2price.png'
  [#options+1] =   'images/shop3price.png'


local priceTag = {}
for i = 1,#options  do
   priceTag[i] = widget.newButton{
      defaultFile = options[i],
      overColor = {128,128,128,255},
      width = 73,
      height = 38,
      left = (centerX-155) + (i-1)*118,
      top = centerY*0.88,
      id = i,
      onEvent = function (e) 
         if e.phase == 'ended' then
            onTouchBuy(e.target.id)
         end
         return true 
     end
   }
  -- priceTag[i] : setReferencePoint( display.CenterReferencePoint )
   priceTag[i] : scale( 0.8 , 0.8 )
   buttonGroup : insert( priceTag[i] )
end

试试这个,应该可以正常工作。