Okay, it’s Yet Another Leak question.
I tried to use from the ‘share code’, the great lightnings effects.
Thx to the really cool Corona Profiler lib, I know that the following code causes a great leak.
I have tried to narrow the issue to a single function. Any help would be welcomed.
[code]
local function doLightnings()
– gundersen code inserted in a Layer :
lines = display.newGroup()
effectLayer:insert(lines)
local function drawLightning(x1, y1, x2, y2, displace, r, g, b)
if displace < 1 then
–glow around lightning
for i = 1, 2 do
local line = display.newLine(x1, y1, x2, y2)
line:setColor(r, g, b)
line.width = 20 / i
line.alpha = 0.05 * i
lines:insert(line)
end
–bolt itself
local line = display.newLine(x1, y1, x2, y2)
line:setColor(r, g, b)
lines:insert(line)
else
local midx = (x2+x1)*0.5
local midy = (y2+y1)*0.5
midx = midx + (mRandom(0, 1) - 0.5)*displace
midy = midy + (mRandom(0, 1) - 0.5)*displace
drawLightning(x1, y1, midx, midy, displace*0.5, r, g, b)
drawLightning(x2, y2, midx, midy, displace*0.5, r, g, b)
end
end
local function timerDraw(e)
timer.cancel( e.source)
drawLightning( 0, 0, _W, _H,100, 255, 100, 100)
local function timerClear(e)
timer.cancel( e.source )
display.remove(lines);
lines = nil
lines = display.newGroup();
effectLayer:insert(lines);
end
timerStash.newTimer = timer.performWithDelay(mRandom(300), timerClear, 1)
timerStash.newTimer = timer.performWithDelay(mRandom(3000), timerDraw, 1)
end
– tmr launch
timerStash.newTimer = timer.performWithDelay(mRandom(2000)+1000, timerDraw, 1)
end
[/code] [import]uid: 9328 topic_id: 19743 reply_id: 319743[/import]