Ok so i am currently creating an app that display a picture everyday until a set date i am using this code for each image to display:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | _H = display.contentHeight; _W = display.contentWidth; mRand = math.random; local function spawnMint() local Mint = display.newImageRect("thumbnail.jpg", 80, 80); Mint:setReferencePoint(display.CenterReferencePoint); Mint.x = mRand(50, _W-50); Mint.y = mRand(50, _H-50); end tmr = timer.performWithDelay(100, spawnMint, 1); <code> But the problem im having is that the images are over laping each other and i want to make it so that it doesnt do that. i have done research on how to fix this but nothing has come up. If you could help me i would appreciate it, thank you. |
It would seem that the pictures are overlapping because you are never removing the previous pictures.
You will need to remove the image or animate it away before you add a new one, if you do not want to see the previous image. And you'll need to declare the image variable outside of the function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | _H = display.contentHeight; _W = display.contentWidth; mRand = math.random; local Mint local function spawnMint() if Mint then display.remove(Mint) end Mint = display.newImageRect("thumbnail.jpg", 80, 80); Mint:setReferencePoint(display.CenterReferencePoint); Mint.x = mRand(50, _W-50); Mint.y = mRand(50, _H-50); end tmr = timer.performWithDelay(100, spawnMint, 1); |
Oh ok thank you.
views:1458 update:2011/12/31 9:35:10