question about image sheets

I’m trying to implement an image sheet that I made in Texturepacker and I there are some things I can’t figure out. And by can’t figure it out I mean that it looks bad and I can’t figure out why.
 
I have 3 .lua files and three .png files. each one is file, file@2x, file@4x
 
I put the .png files in a folder called images in the resources directory.
 
I am using the corona recommended ultimate config.lua file.
 
First question: Do I need to require all three .lua modules or does the image suffix thing work for all of them?
 
Second question, do I need to figure out which of these tables to use or is there a built in way to do that? If I need to do it in the code, I don’t understand the benefit of using the config file suffix thing.
 
I read this:
 ----------------------
Important
 
This feature is only supported by images displayed using display.newImageRect() or by sprites and images taken from image sheets that contain the overall sheet size parameters.


I’m not sure how sheet parameters are implemented, do I add the size of the entire sheet to every single entry in the sheet.lua file? That seems kind of… well, messy, to copy and paste it in every single definition.

sheetContentWidth =70-- width of original 1x size of entire sheet
sheetContentHeight = 82 – height of original 1x size of entire sheet

Finally, I have a border that is a 1 pixel wide by 6 pixel long file that I stretch. It seems that the image sheet is swallowing it, probably because it is being added to the @4x version and you can’t reduce an image that is one pixel wide. Is it best to just leave it out of the image sheet or should I blow it up to 4 px x 24 px?

Ok, I’ve been messing with this for a while now and I figured a few things out. Mostly, I’m figuring out that I probably should stop using image sheets.

First, I realized that texture packer is putting in sheetContentWidth for me, I just didn’t see it for a while.

I took that border out of the texture, it seems that combining image sheets and the technique of stretching borders is not really compatible, it seems to create translucent pixels around each image and that becomes exaggerated when you stretch it.

I still can’t decide how to use the multiple .lua files, if you can give advice on that I still need it. does Corona just extrapolate where the images are in each sheet based on where they are in the first sheet?

Also, I got my first out of memory crash for the app after I used texture packer… that is not a good sign.

I packed up everything, even the backgrounds, maybe I should not have packed up the background images?

Hi @mark_steelman,

You just need to include all files generated by Texturepacker (3 lua & 3 png) in your project folder.

But just require one (without suffix). And all reference to size, position will be based on this.

The reason you need to use display.newImageRect instead of display.newImage because the latter does not support dynamic scale.

Using the display.newImageRect, Corona will select which suffix to use.

For example, normally, @2x suffix is called for iPad while @4x suffix for iPad retina display.

So, corona will get the appropriate image to display.

You also have to set imageSuffix in your config.lua.

Read here for detailed explanation http://docs.coronalabs.com/guide/basics/configSettings/index.html

As for the background image you still can include if your total overall size is not too big. But I prefer not to include.

Good Luck!

burhan

Ok, I’ve been messing with this for a while now and I figured a few things out. Mostly, I’m figuring out that I probably should stop using image sheets.

First, I realized that texture packer is putting in sheetContentWidth for me, I just didn’t see it for a while.

I took that border out of the texture, it seems that combining image sheets and the technique of stretching borders is not really compatible, it seems to create translucent pixels around each image and that becomes exaggerated when you stretch it.

I still can’t decide how to use the multiple .lua files, if you can give advice on that I still need it. does Corona just extrapolate where the images are in each sheet based on where they are in the first sheet?

Also, I got my first out of memory crash for the app after I used texture packer… that is not a good sign.

I packed up everything, even the backgrounds, maybe I should not have packed up the background images?

Hi @mark_steelman,

You just need to include all files generated by Texturepacker (3 lua & 3 png) in your project folder.

But just require one (without suffix). And all reference to size, position will be based on this.

The reason you need to use display.newImageRect instead of display.newImage because the latter does not support dynamic scale.

Using the display.newImageRect, Corona will select which suffix to use.

For example, normally, @2x suffix is called for iPad while @4x suffix for iPad retina display.

So, corona will get the appropriate image to display.

You also have to set imageSuffix in your config.lua.

Read here for detailed explanation http://docs.coronalabs.com/guide/basics/configSettings/index.html

As for the background image you still can include if your total overall size is not too big. But I prefer not to include.

Good Luck!

burhan