Replicate images

Hello,

I’m learning LUA and trying to make a game.

My first difficult was to replicate the images, in different positions.

Since they’re many repetitions, anybody has any advice about how to proceed in this case?

My ideia (it’s not working):

leaf = {}

for p = 60,650 do

    index=index+index

    local leaf [index] = display.newImage (“leaf.png”, p, 220)

    leaf[index]:scale (0.9,0.9);

end

Thank you in advance!

Try the following:

local leaf = {}   for i= 1, 20 do --This creates 20 objects but you should create as many objects as you want    local new\_leaf = display.newImage("leaf.png")    new\_leaf.x, new\_leaf.y = 10\*i, 220 -- I used 10, but you should use the width of the image    new\_leaf.xScale, new\_leaf.yScale = 0.9, 0.9    leaf[i]=new\_leaf end

Try the following:

local leaf = {}   for i= 1, 20 do --This creates 20 objects but you should create as many objects as you want    local new\_leaf = display.newImage("leaf.png")    new\_leaf.x, new\_leaf.y = 10\*i, 220 -- I used 10, but you should use the width of the image    new\_leaf.xScale, new\_leaf.yScale = 0.9, 0.9    leaf[i]=new\_leaf end