13 October 2014
Corona Geek #111 – Texture Memory Management and Ultimate Config.lua Revisited
During this week’s Corona Geek Hangout, Corona Ambassador Ed Maurina shared texture memory management tips for freeing up texture memory when you have to display and retain many hundreds to thousands of images on and off-screen. Also Corona Ambassador Sergey Lerg shared his config.lua solution for scaling content to fit the most common screen sizes, including iPhone 6 and 6 Plus.
Compete In The “Geek Games”
Remember to put your gaming skills to go use. Post your 2048 Hex high score to the Corona Geek Facebook wall for a chance to win a $50 gift card to a retailer of your choice! Multiple entries are allowed. Post each time you get a new high score. A winner will be announced on November 3rd. We’ll remind you throughout the month. Good luck!
Replay Last Week’s Show
Resources
- Burtons Media Group – Corona Books
- Roaming Gamer – Game Templates and Tools
- Spiral Code Studio – Corona Games and Development
- Swipe Parental Gate
- AT&T Doubles Data Plans
- Game Center moved to plugin
Thank you for listening to and following Corona Geek:
Marcotronic
Posted at 00:21h, 14 OctoberThanks a lot for this video! Your ultimate config.lua looks very good and I really like the idea. I’m wondering now, though, how to deal with it when actually designing graphics. Let’s say I want to create the “ultimate” background image in Photoshop: Which perfect “main area” without potential bleed would I have to design (width, height) – the area that will definitely be visible on each and every device and how much additional bleed in pixels would I have to add (width, height) – to make sure every potential device won’t have any letterboxing borders.
I want to create some photoshop templates with guides for “safe” areas and bleeding areas at a maximum resolution and create some actions to scale this image down to lower resolutions that may be needed. I would happily share this photoshop template and the photoshop actions if I knew what the “perfect” solution looked like 🙂
thanks
Marco
Lerg
Posted at 21:35h, 14 OctoberHi, thank you!
Regarding background image, take the most ridiculous android device with resolution 400×854 and put it into the trash, targeting such devices is a waste of time. Now take a reasonable most wide android device 480×854 – aspect ratio is 1.77916, which is just a little bigger than for iPhone 6 – 1.7786. Take a safe 1.78 aspect ratio.
Now that you are certain with aspect ratio, you can create any image with such width and height and it will cover all devices when properly scaled (“zoom even” scale).
Now take the highest resolution with highest height (let’s assume you are making a landscape app). That is 1600×2560. Now you have height (1600), you have aspect ratio 1.78, you can calculate the width:
1600 * 1.78 = 2848, which is perfect, because it can be divided by 8 with no remainder (2848 / 8 = 356).
That’s it, you have 1600×2848 scalable background@4x that covers all devices using zoom even method:
local s = _H / bg.height
bg:scale(s, s)
If you don’t scale, your background will be pixel perfect when available, but will have smaller safe zone.
Marcotronic
Posted at 22:31h, 14 OctoberThanks a lot for your answer! 🙂
Marco
Michael
Posted at 10:50h, 14 Octobera big thank you to Sergey for his fantastic config.lua. this will make it simple to handle the different devices and there resolutions. cool idea!
Lerg
Posted at 21:36h, 14 OctoberYou are welcome!
Michael
Posted at 08:43h, 19 Octoberworks perfect for my sprites and co, but unfortunately it will not solve the problem with background pictures and the different sizes on different devices…
Lerg
Posted at 21:36h, 14 OctoberOn a side note, I realized I should have given this config lua file a distinct name. Any suggestions for the name?
Look like “the best config.lua” or “awesome config.lua” are not working.
Lerg
Posted at 21:51h, 14 OctoberHow about “Spiral config.lua”? Because my company name is Spiral Code Studio.
Bob
Posted at 06:48h, 15 OctoberSpiral config is good I think — unique enough to search for and remember. And also let me add my thanks for sharing this config code with us!
Prathap Murthy
Posted at 20:03h, 16 OctoberAbsolute config.lua
Lerg
Posted at 09:09h, 17 OctoberMaybe “Smart config.lua” ?
Prathap Murthy
Posted at 09:33h, 17 OctoberYeah, that works too.