Help with confing and imageSuffix

Hello everyone.

Even though my app is now almost ready, it seems to me right to include my question here…

I’ve always worked well with this standard config:

application = { content = { width = 320, height = 480, scale = "letterbox", fps = 60, imageSuffix = { ["@2x"] = 2, ["@4x"] = 4, }, }, }

However, so far I’ve used high resolution images and it’s time to export. I read this:

https://coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/

 And I got in a little panic.

With my current confing if i want to export the pictures for all the screens which is the best solution? Do I have to change confing? If it is needed there is no problem, but I want 2 or 3 images to export images well on more devices. You can give me explanations and tell me how to act. thank you so much

I would recommend that you stay with what you have with one minor change:

application = { content = { width = 320, height = 480, scale = "letterbox", fps = 60, imageSuffix = { ["@2x"] = 1.5, --\<---- changed from 2 to 1.5 ["@4x"] = 3, --\<---- changed from 4 to 3 }, }, }

When you have your @2x images set to 2.0, what you will find is that screens 639 px wide and less will get the 1x image. 640 to 1279px wide would get the @2x images and 1280+ would get the @4x images.  Devices like the Kindle Fire are 600px wide devices, that means that Corona has to scale up the 1X images up quite a bit (87.5%) to make it fit that screen, where as if you had the @2x images you’re only scaling them down 6.67% and scaling down is always better than scaling up.

By using 1.5 and 3.0 for the values, now 1x images are used for screens less that 480px side. Your @2x images get used for screens between 480 and 959 an your @4x images get used on 960+px.

Rob

Thank you

The second time you help me in a day. I like to keep this config because among those I’ve tried I think is the best. In a few words you have explained many of my doubts.

Only a small thing is unclear if my 1x image (ex.  “palla.png”) is 100*100, my image “ball@2x.png” is 150*150 and  “ball@4x”.png" is 300*300?

So is it correct?

No. If ball.png is 100x100, then ball@2x.png would be 200x200 and ball@4x.png would be 400x400.  The values (1.5 and 3) in config.lua tells Corona at what screen size it should switch. The images themselves still need to be 2x and 4x in size.

Rob

Ok perfect thanks a thousand.

At this point I have another small question I had not thought of at the beginning.

Is it enough for pre-charging or does it need something for other resolutions?

local texture = graphics.newTexture( { type="image", filename="ball.png" } ) texture:preload() local ball= display.newImageRect( texture.filename, texture.baseDir, 100, 100 )

graphics.newTexture() knows how to use the @2x and @4x images correctly.

Rob

You fixed me hours of thought thank you

The only issue with this schema is old iPads… if you have a LOT of graphics then the 1.5x loads retina graphics on non-retina capable devices and this causes issues with memory.

Note: it is not an issue until you are allocating more than 100MB of assets.

The non-Retina iPads are 768px wide. Under this schema they would pick up the @2x assets which would be appropriate for the non-Retina iPads. The 4x assets won’t get picked up until you hit 960px wide on the short side.

That said, the @2x assets will add up to a lot of memory in a hurry.  For instance if you’re following the 360x570 background that is recommended, it’s really a 512x1024x4 texture or a 2 megabyte image. If the 4x got loaded it would be a 1024x2048x4 image or an 8mb image.

Rob

I do not think I get to 100 Mb but I could go very close …

Is there something I can do to reduce the issues with memory? Pre-charging is not enough?

I see many applications, even 3D (so very heavy) around …

Other than cutting the amount of assets or their size there is not a lot you can do as a png will always be a 32 bit texture even if you supply an 8 bit highly compressed png in your apk.

My game, which allocates 100MB texture and at least 90MB Lua memory, sometimes gets shut down on iPad2 if the user has any other memory hog running - like Facebook.

I understand, in this case there are no more tricks …

Thanks again for your time

You can keep old scenes purged. You can watch your image sizes. Don’t make a 68x68 pixel image since it becomes a 128x128, make it 64x64. It will be 1/4th the size in memory. Each jump in Power of Two’s is a 4X increase in size since you’re doubling the size on two axis. If your image must be 68x68 on screen, have the image be 64x64 and tell display.newImageRect() to create it at 68x68. It will scale up a little, but it’s manageable. Avoid a lot of transparency around image too. I had a client once gave me an animation for a character that was supposed to take up roughly half the screen vertically and horizontally, but there was transparency that made the images fit the screen. In other words, on our 320x480 screen, each frame was 320x480 though the character was more like 160x240. The images were way larger than they needed to be. Once I trimmed them in, I saved a ton of memory.

Use ImageSheets where you can and keep them power of two based.  It will save a lot of memory. 

Rob

Wow very straight.

I had not thought about making 64x64 if the picture was a little bigger. For transfection I had already thought about it. ImageSheets are very useful for animations but for other images tend to complicate you read things, I prefer to use them only in case of an emergency. Small tips that solve great losses!

Thank you

Image sheets should always be used as this limits the draw calls open GL has to make and therefore your app will render faster.

This is true but every time I add or remove an image from a Image sheets I need to rebuild the sheet.

In my game there are characters and costumes for each addiction I should review everything or wrong? Also would there be very large sheetsnot a problem for lua loading?

I have about 60 characters 40*40 then a sheet 2400 * 2400. My @4x 160*160 then a sheet 9600 * 9600.

And with each update I would like to increase the number of characters

Use texture packer to create your image sheets as this automates the process.  You can have multiple image sheets if the total size of your assets is greater than 2048x2048

Hello

Sorry if I reappraise this topic but it seemed useless to open a new one.

The fact is this by following the Rob council I did everything I needed and it works. I would just ask a question. Some of the backgrounds I use to avoid empty areas are 360 * 570. That is, the maximum in height and width. So my image @4x comes 1440 * 2280 and is about 2Mb. This is fine? Is not it too much for loading?

thank you so much

on high-end devices this is not an issue really.

Fine infinite thanks.

I asked this because I’m creating a sliding game I noticed that if I load about 25 images 960 * 1920 the game lag and any physical moves slow down a lot. Is there a quantity of memory that would be better not to overcome?