Alright so picture in your mind the latest flappy bird clone but please keep reading…
Originally I used transition.to for the floors and pipes and it works very smoothly on iOS. However when I built it for Android it had a tendency to be very choppy randomly on certain hardware. I tried a lot of things, and eventually decided to switch to an enter frame listener. Slight improvement but still randomly choppy. I then aded a delta time calculation into it to try and compensate but again still very choppy.
I also tried a pre graphics 2 build - slight difference but still unacceptable.
So then I decided to go back to basics and set this project up.
Config file:
application = { content = { width = 320, height = 480, scale = "letterBox", fps = 60, }, }
main.lua:
local maxX = 480+((display.pixelHeight \* display.contentScaleX) - 480)/2 local minX = 480-((display.pixelHeight \* display.contentScaleX) + 480)/2 local floor = {} for i = 1,5 do floor[i] = display.newRect(0,0,100,100) floor[i].x = maxX+200\*(i-1) floor[i].y = 160 end local endPos = minX-floor[1].width local runtime = 0 local gameSpeed = -3 local function floorControl() local function getDeltaTime() local temp = system.getTimer() local dt = (temp-runtime) / (1000/60) runtime = temp return dt end local dt = getDeltaTime() for i = 1, #floor do floor[i]:translate(gameSpeed\*dt, 0) if floor[i].x \< endPos then floor[i].x = floor[i].x+1000 end end end Runtime:addEventListener( "enterFrame", floorControl )
Again I built for the device and even moving these 5 rectangles across the screen is far from smooth.
So I added the loq_profiler lib into the code and I notice that randomly the frame rate drops from ~57 fps to 40fps then jumps back up. Why?
The two devices in question are a samsung galaxy s2 tab and and an icoo D70 pro tablet. Both showing similar drops in frame rate randomly. In fact with a static rectangle the samsung device was dipping down into the 40’s too.
On other hardware like Galaxy S3 and HTC Desire S things run a lot smoother.
Is this a limitation of Corona, a Corona bug or am I doing something fundamentally wrong?
Opinions welcome.