Performance issue with large number of images.

I have a very simple test app. The "animate" method moves a square across the screen one pixel at a time and displays the current FPS. It runs fine on my device, playing at 30 FPS. When I tap the square it creates 800 small lines across the screen. Suddenly the FPS drops to <10 and stays there. I understand that creating so many objects could cause a memory issue, but why would it affect the FPS performance?

Here's my main.lua:

-------------------------------------
function makeLines()
for x=1,800 do
local line = display.newLine(x,250,x,252)
end
end

function tap(event)
if (not lines) then
makeLines()
lines = true
end
end

lines = false
prevTime = system.getTimer()
counter = 0
textFPS = display.newText("0", 200, 200, native.systemFont, 12)

square = display.newRect(0,0,100,100)
square:addEventListener("tap",tap)

Runtime:addEventListener("enterFrame", animate)
-------------------------------------

For what it's worth, I am using this strategy because I want to have a line across the screen that I can vary the alpha value of on a pixel by pixel basis. Anyone have a suggestion for a less intensive solution?

Thanks very much.

Update: Creating all those lines has negligible impact on memory.

views:1593 update:2011/9/25 12:40:18
corona forums © 2003-2011