hi guys, I was testing my game on ipad 3 and noticed severe lags when I am switching scenes. I am user a scene manager.
Turned out it is background images I use for the scenes - if I comment out the section that sets background in scene init class, lags will be gone.
Here is how i set background images:
local bg = Bitmap.new(Texture.new(packs[self.curPack].mapBGImage,true))
bg:setAnchorPoint(0.5,0.5)
bg:setPosition(dxmax/2,dymax/2)
self:addChild(bg) |
My project dimensions are 800x480 and use normal scale images and
@2x scale images. On my ipad 3 it would use
@2x scale and my bg image dimensions will be 1704x1200 at
@2x.
The image itself is jpeg and average size for
@2x image is 200-250kb.
Any ideas how to remove this lag? Will TexturePack help in this case? Since images are big I thought they would not make a difference and the pack would be huge.
Comments
And you might be able to preload only 5 or less images before the garbage collector kicks in.
Now that the source is open, I may look at loading the image in a different thread if I ever get some free time .
Likes: boriskey
You may preload the bg on game start and keep it in memory (like in global variable) if you need that scene to load quicker.
What I usually do is dim the screen and display loading text, between scenes:
http://giderosmobile.com/forum/discussion/3733/implement-loading-scene-/p1
Likes: boriskey
Example:
Likes: boriskey
BUT the RAM utilization on iPAD jumped from 60Mb to 130Mb (according to Xcode)
Is that a bad thing? I am reading that the best practice is to keep RAM utilization around 50-60Mb especially for older devices.
The wait icon and dimming screen works, but the user experience is not great though since users will see that a lot.
I guess the best solution will depend on your textures size.
I am reading that the best practice is to keep RAM utilization around 50-60Mb especially for older devices.
------->this line must be for older device like iphone 3g,3gs, ipad 1 which are currently not supported so you can ignore that
Likes: jdbc
I implemented a load image as suggested above by @ar2rsawseen for now, funny thing I 've spent 2 hours picking a nice animated load spinner when I realized that animated load indicator cannot be done in Gideros
I was trying to preload next/previous backgrounds but it still makes things laggy because Gideros cannot load images asynchronously.
So I am not happy but it is what it is.
good to know about mini - I was actually testing my app on nexus 5 as well and the lag is not that noticeble also.
BTW I found quite a few old threads from 2012 - people complaining about this, stating that Corona and Cocosx are using much faster libs to load textures and doing this asynchronously. So I guess this was never improved. For some games, it is actually a pretty big deal.
I also have a couple other games published that use many full screen background images and both native java android code and objective c were handling them quite well with no lags at all. I did use some weak references to cache 4-5 images and free them up dynamically but even then there were no lags even on very old android devices.