You’re not accounting for the fact that frame times vary.
One frame may take 20 ms, another 16, another 10, etc.
I answered a similar question here:
https://forums.coronalabs.com/topic/56853-stuttering-when-moving-display-objects-across-screen/
You’re not accounting for the fact that frame times vary.
One frame may take 20 ms, another 16, another 10, etc.
I answered a similar question here:
https://forums.coronalabs.com/topic/56853-stuttering-when-moving-display-objects-across-screen/
Hi roaminggamer. I have modified my code as below:
local speed = 100 -- strip out other line I posted -- local currentTime = system.getTimer( ) local dt = currentTime - lastTime lastTime = currentTime local dx = dt \* speed \* 0.001 cloud.x = cloud.x - dx -- -- strip out other line I posted
That will calculate dx by time has passed in every frame. The problem still exist :(.
I also tried to log the dt out in the console and noted that there are many big stutter time almost constantly happen. See the log.
Corona Simulator[8969:403112] 16.959
Corona Simulator[8969:403112] 14.88
Corona Simulator[8969:403112] 15.917
Corona Simulator[8969:403112] 15.381
Corona Simulator[8969:403112] 16.279
Corona Simulator[8969:403112] 22.121
Corona Simulator[8969:403112] 9.4779999999996
Corona Simulator[8969:403112] 15.892
Corona Simulator[8969:403112] 23.623
Corona Simulator[8969:403112] 9.2939999999999
Corona Simulator[8969:403112] 16.029
Corona Simulator[8969:403112] 15.074
Corona Simulator[8969:403112] 16.339
Corona Simulator[8969:403112] 15.864
Corona Simulator[8969:403112] 17.545
Corona Simulator[8969:403112] 14.664
Corona Simulator[8969:403112] 15.819
Corona Simulator[8969:403112] 17.14
Corona Simulator[8969:403112] 14.412
Corona Simulator[8969:403112] 26.372
Corona Simulator[8969:403112] 6.6419999999998
Corona Simulator[8969:403112] 15.63
Corona Simulator[8969:403112] 16.32
Corona Simulator[8969:403112] 15.388
Corona Simulator[8969:403112] 16.038
Corona Simulator[8969:403112] 15.15
Corona Simulator[8969:403112] 17.113
Corona Simulator[8969:403112] 15.713
Corona Simulator[8969:403112] 15.351000000001
Corona Simulator[8969:403112] 16.003
Corona Simulator[8969:403112] 15.996
Corona Simulator[8969:403112] 22.138
Corona Simulator[8969:403112] 10.069
Corona Simulator[8969:403112] 16.653
Corona Simulator[8969:403112] 16.086
I also look into your answer in the post you referenced me. Try to run all your suggestion code but they’re stuttering the same as the video I attached. Anything I should do to make it smooth? Thanks!
Are you trying to run at 60 FPS? It looks like you’re doing too much work in some frames and this is killing your frame rates.
Try setting fps = 30 in config.lua.
application = { content = { width=320, height=480, fps = 30, scale = "letterbox" }, }
My test has 24 lines of code like I posted above, just moving an image constantly from right to left of course at 60 fps.
As you said, I have set the fps to 30 and noted that there’re not many stutter dt like in fps60. It’s strange. With the fps30 the cloud moving isn’t quite smooth as expected.
I’m using the latest daily build SDK. Don’t know why at fps60 it’s quite stutter, may it be a bug with the Corona SDK? I see many people have the same problem.
Your best bet is to make a very small example (I mean less than 50 lines of code) that demonstrates and reproduces the issue. Then you can file a bug. Don’t forget to give details (in the bug):
This is my code, I have made some optimization but the choppy frames still exist.
local getTimer = system.getTimer local cloud = display.newImage( "cloud.png", 300, 100) cloud.xScale = 0.4 cloud.yScale = 0.4 local w = cloud.width local haftW = cloud.width \* 0.5 local speed = -200 -- move from right to left local lastTime = getTimer( ) local function frameUpdate( event ) local currentTime = getTimer( ) local dt = currentTime - lastTime lastTime = currentTime --print(dt) local dx = dt \* speed \* 0.001 cloud:translate(dx, 0) if (cloud.x \< -haftW) then cloud:translate(display.contentWidth + w, 0) end end Runtime:addEventListener( "enterFrame", frameUpdate )
Full zip project here https://www.dropbox.com/s/kkok4m5g8htz01v/TestSmooth.zip?dl=0
All corona simulator and Android emulator and my device Xperia Z1 have the same stutter issue. Check this video as a demonstration https://goo.gl/bSfQyI
I’m using Corona SDK version 2015.2642.
The choppy frames appear frequently rather randomly.
Please help and thanks so much!
download link is disabled.
These all look jerky in the simulator, but fine on my Generation 1 Nexus 7
Hope this helps.
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/05/TestSmooth.zip
Thanks for your help roaming! I tried on my Z1 but it still gets jerky. The Nexus 7 of my friend looks fine.
You’re not accounting for the fact that frame times vary.
One frame may take 20 ms, another 16, another 10, etc.
I answered a similar question here:
https://forums.coronalabs.com/topic/56853-stuttering-when-moving-display-objects-across-screen/
Hi roaminggamer. I have modified my code as below:
local speed = 100 -- strip out other line I posted -- local currentTime = system.getTimer( ) local dt = currentTime - lastTime lastTime = currentTime local dx = dt \* speed \* 0.001 cloud.x = cloud.x - dx -- -- strip out other line I posted
That will calculate dx by time has passed in every frame. The problem still exist :(.
I also tried to log the dt out in the console and noted that there are many big stutter time almost constantly happen. See the log.
Corona Simulator[8969:403112] 16.959
Corona Simulator[8969:403112] 14.88
Corona Simulator[8969:403112] 15.917
Corona Simulator[8969:403112] 15.381
Corona Simulator[8969:403112] 16.279
Corona Simulator[8969:403112] 22.121
Corona Simulator[8969:403112] 9.4779999999996
Corona Simulator[8969:403112] 15.892
Corona Simulator[8969:403112] 23.623
Corona Simulator[8969:403112] 9.2939999999999
Corona Simulator[8969:403112] 16.029
Corona Simulator[8969:403112] 15.074
Corona Simulator[8969:403112] 16.339
Corona Simulator[8969:403112] 15.864
Corona Simulator[8969:403112] 17.545
Corona Simulator[8969:403112] 14.664
Corona Simulator[8969:403112] 15.819
Corona Simulator[8969:403112] 17.14
Corona Simulator[8969:403112] 14.412
Corona Simulator[8969:403112] 26.372
Corona Simulator[8969:403112] 6.6419999999998
Corona Simulator[8969:403112] 15.63
Corona Simulator[8969:403112] 16.32
Corona Simulator[8969:403112] 15.388
Corona Simulator[8969:403112] 16.038
Corona Simulator[8969:403112] 15.15
Corona Simulator[8969:403112] 17.113
Corona Simulator[8969:403112] 15.713
Corona Simulator[8969:403112] 15.351000000001
Corona Simulator[8969:403112] 16.003
Corona Simulator[8969:403112] 15.996
Corona Simulator[8969:403112] 22.138
Corona Simulator[8969:403112] 10.069
Corona Simulator[8969:403112] 16.653
Corona Simulator[8969:403112] 16.086
I also look into your answer in the post you referenced me. Try to run all your suggestion code but they’re stuttering the same as the video I attached. Anything I should do to make it smooth? Thanks!
Are you trying to run at 60 FPS? It looks like you’re doing too much work in some frames and this is killing your frame rates.
Try setting fps = 30 in config.lua.
application = { content = { width=320, height=480, fps = 30, scale = "letterbox" }, }
My test has 24 lines of code like I posted above, just moving an image constantly from right to left of course at 60 fps.
As you said, I have set the fps to 30 and noted that there’re not many stutter dt like in fps60. It’s strange. With the fps30 the cloud moving isn’t quite smooth as expected.
I’m using the latest daily build SDK. Don’t know why at fps60 it’s quite stutter, may it be a bug with the Corona SDK? I see many people have the same problem.
Your best bet is to make a very small example (I mean less than 50 lines of code) that demonstrates and reproduces the issue. Then you can file a bug. Don’t forget to give details (in the bug):
This is my code, I have made some optimization but the choppy frames still exist.
local getTimer = system.getTimer local cloud = display.newImage( "cloud.png", 300, 100) cloud.xScale = 0.4 cloud.yScale = 0.4 local w = cloud.width local haftW = cloud.width \* 0.5 local speed = -200 -- move from right to left local lastTime = getTimer( ) local function frameUpdate( event ) local currentTime = getTimer( ) local dt = currentTime - lastTime lastTime = currentTime --print(dt) local dx = dt \* speed \* 0.001 cloud:translate(dx, 0) if (cloud.x \< -haftW) then cloud:translate(display.contentWidth + w, 0) end end Runtime:addEventListener( "enterFrame", frameUpdate )
Full zip project here https://www.dropbox.com/s/kkok4m5g8htz01v/TestSmooth.zip?dl=0
All corona simulator and Android emulator and my device Xperia Z1 have the same stutter issue. Check this video as a demonstration https://goo.gl/bSfQyI
I’m using Corona SDK version 2015.2642.
The choppy frames appear frequently rather randomly.
Please help and thanks so much!
download link is disabled.
These all look jerky in the simulator, but fine on my Generation 1 Nexus 7
Hope this helps.
https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2015/05/TestSmooth.zip
Thanks for your help roaming! I tried on my Z1 but it still gets jerky. The Nexus 7 of my friend looks fine.