objects in a table

I have a spawn function that spits out images where I want them on the screen (where the garden is, in the middle of the screen) randomly

heres the function that controls that

1
2
3
4
5
6
function spawn()
        local object = display.newImageRect("weed.png", 200, 150 )
        object.x = math.random(300,600); object.y = math.random(300,600)
        object:addEventListener("tap", tapped)
        objects[object] = object
end

This kind of worked but they are still on top of each other!

1
 object.x = (math.random(500,700)-object.contentWidth); object.y = (math.random(500,700)- object.contentHeight)

I put things in a table and it seemed to do the trick!!

views:1496 update:2011/10/26 17:27:57
corona forums © 2003-2011