Hello,
I noticed that the start of the transitions in Corona can get sloppy when they are executed after doing some heavy code before that.
For example in my game I execute a transition after my map is loaded. The loading of the map is quiet heavy which makes my map transition (2 rectangles sliding away) act laggy. If I put a timer.performWithDelay after the heavy function the lag is gone.
I made an example main.lua which is located below, what I want to know is why this is happening? The lua code is executed non-parralel right? Is this the garbage collector doing stuff in the background?
Ps. for this example it’s best to turn on 60fps, the green rect moving is WITH a timer.performWithDelay and the red rect is WITHOUT. So the red rect is the one acting sloppy in my simulator and phone. You can edit the amount in the for loop to work better on the pc you’re using.
local heavyLoad local rect = display.newRect(0, 0, display.contentWidth, display.contentHeight) rect.y = display.contentCenterY rect.x = display.contentCenterX + display.contentWidth - 10 local count = 0 local function doTransition() transition.from(rect, {x = display.contentCenterX, time = 300}) timer.performWithDelay(3000, heavyLoad) end heavyLoad = function() --Heavy load function count = count + 1 for i=1, 100000, 1 do local test = display.newRect(0, 0, 1, 1) display.remove(test) end if count % 2 == 0 then rect:setFillColor(1, 0, 0) doTransition() else rect:setFillColor(0, 1, 0) timer.performWithDelay(1000, doTransition) end end timer.performWithDelay(500, heavyLoad)
I just adjusted my actual code to work with coroutines (divided into multiple yields), and it’s looks like it is a consistent clean transition after loading the map now ^^