2x automatically scaled down?

I am trying to get rid of lower-resolution spritesheets, and only use high-resolution ones. I’m doing it to make my app significantly smaller, since my app has about 70 mb of art. However, I’ve come across a strange problem:

When I use @2x spritesheets with @2x information exported from TexturePacker, all my sprites are displayed at double their original size, instead of automatically being scaled back to look the same as @1x sprites. When I use @2x spritesheets with @1x (no image suffix) information, everything is fine, and the sprite is displayed as normal, but at a higher resolution – this is what I want to see. It seems that Corona automatically scales it down, even though the spritesheet file, buttons.png, has no @2x in it. That is, it’s correctly using the sheet information for a spritesheet where all the dimensions need to be halved. Can anyone tell me:

  1. Why is this working?

  2. Is there a suggested way to transition to using only @2x images without screwing up your ui layout? I have a large code base, but I want to do it the “real” way. Hopefully this doesn’t involve manually editing hundreds of sprite instances. 

I’ve attached a project showing the issue – buttons.lua is @1x, and buttons.png is exported @2x, but it shows just fine.

Help!

You are missing the @2x reference in config.lua

 content = { imageSuffix = { ["@2x"] = 2 } },

Adding @1x images shouldn’t increase your apk size by very much and will stop lower end devices maxing out on texture memory

@adrianM:

  1. I understand I’m missing the @2x reference. That’s what’s confusing me – even without the @2x reference, it’s still loading properly. Why is it working? That’s my question.

  2. I appreciate your concern, but my game doesn’t use so much memory at one time that it matters on slower devices. Having @1x images will will increase my app’s size significantly – by at least 10 or 15 mb. I have a lot of art, and having a larger app just means fewer people will download it. Hence my downsizing.

If you don’t want image scaling then make sure your sprite sheet has the same dimensions as your image sheet.  In your zip - your image sheet is 1024 x 2048 but your sprite sheet is only 512 x 1024.

But your config.lua is set to 320 x 480 so everything will be jumbo-sized without the @2x handling (which maps 4 image pixels to 1 corona pixel).  So you would need to change your config.lua to this

application = { content = { width = 640, height = 960, scale = "letterBox", fps = 30, }, }

You are missing the @2x reference in config.lua

 content = { imageSuffix = { ["@2x"] = 2 } },

Adding @1x images shouldn’t increase your apk size by very much and will stop lower end devices maxing out on texture memory

@adrianM:

  1. I understand I’m missing the @2x reference. That’s what’s confusing me – even without the @2x reference, it’s still loading properly. Why is it working? That’s my question.

  2. I appreciate your concern, but my game doesn’t use so much memory at one time that it matters on slower devices. Having @1x images will will increase my app’s size significantly – by at least 10 or 15 mb. I have a lot of art, and having a larger app just means fewer people will download it. Hence my downsizing.

If you don’t want image scaling then make sure your sprite sheet has the same dimensions as your image sheet.  In your zip - your image sheet is 1024 x 2048 but your sprite sheet is only 512 x 1024.

But your config.lua is set to 320 x 480 so everything will be jumbo-sized without the @2x handling (which maps 4 image pixels to 1 corona pixel).  So you would need to change your config.lua to this

application = { content = { width = 640, height = 960, scale = "letterBox", fps = 30, }, }