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
[lua]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[/lua]
Its also connected to a for loop
[lua]for i = 1, 5 do
spawn()
end
[/lua]
The problem is that the images are to crowded and spawn on top of each other… In a previous project I did something like this so that they would show up on top of each other.
[lua]local function createRC()
local i
for i = 1, 3 do
circleRed[i] = display.newImageRect(“rc.png”, 80, 80)
circleRed[i].x = rand(screenW - circleRed[i].contentWidth)
circleRed[i].y = rand(screenH / 2, screenH - circleRed[i].contentHeight)
circleRed[i].touched = false
circleRed[i].isVisible = false
circleRed[i]:addEventListener(“touch”, flagCircle)
end
end[/lua]
So that the red circles don’t show up on top of each other and spawn on the bottom half of the screen… How do I accomplish the same thing with information I have on top with the spawn function. While keeping the math.random(300,600)
[import]uid: 51459 topic_id: 16912 reply_id: 316912[/import]