imagesheet and layout issues

I might be mistaken, but I believe if you use those last 4 parameters… sourceX, sourceY, sourceWidth, sourceHeight… you’re telling Corona that you actually WANT to trim the sheet and ignore the transparent pixels around. Apparently you don’t want to do that… you want to keep those pixels as part of the overall map, so the positioning works out properly.

Those 4 parameters are totally optional with image sheets. They are useful, and necessary, for ultra-controlled trimming and optimization. But if you want to recognize the sheet with transparent boundaries around, don’t specify them. Again, this is what Texture Packer does “beyond Corona” when you might not actually want that to occur.

Corona offers them because many developers want extreme control over sheet trimming, frame padding, etc… but they remain optional.

Brent [import]uid: 9747 topic_id: 32544 reply_id: 129624[/import]

there are a lot of options w/ texture packer, and it is likely it is something I am picking, I just can’t figure it out. When I select “trim” it adds those in.

If I tell it not to trim/crop, it doesn’t add them, but then again it doesn’t trim the pixels out, and there is no benefit, it is just a full size ipad retina image in an imagesheet. I’m trying to trim the pixels, but bring them back at runtime. Is this possible? If so, what should my imagesheet look like?

Any idea on the second issue? When I don’t use the map in an image sheet and call it directly from 1x/2x/4x I have another problem that looks very much like a Corona bug. All devices look perfect, but the iPad retina shows horizontal stretching but no horizontal stretching but my 4x images are perfect and layout 100% pixel perfect. [import]uid: 160288 topic_id: 32544 reply_id: 129625[/import]

By the way, I did change settings, and tested it previously without sourceheight/width, and it did not change the fact it loads the image content only ignoring all the transparent pixels and made it full screen.

This is without sourceheight/width

http://screencast.com/t/EH6wMAaaenU [import]uid: 160288 topic_id: 32544 reply_id: 129629[/import]

This is a very strange issue…

I hesitate to play the “blame game”, but this could be an issue with TexturePacker… seriously. I don’t know how it manages things, and I don’t know how that “cut” function works. Just saying that when you use a 3rd-party tool outside Corona, you’re susceptible to what that product does within Corona. Considering this seems like a “packing” or “clipping” issue, it might very well be TexturePacker which is the culprit.

Also, I should note that with image sheets, you don’t need to use the “newImageRect()” API and specify width and height. Those parameters are specified in the image sheet configuration and they are used by the standard “newImage()” API for full resolution-dynamic picking. I never use “newImageRect()” anymore, since image sheets were rolled out earlier this year.

Brent [import]uid: 9747 topic_id: 32544 reply_id: 129621[/import]

I tried without Rect and x,y, the problem is it pulls the content back as if it was just the image in the middle, ignoring the transparent pixels clipped.

Here is the entire sheet information for that image by itself (as created by Texture Packer). The image is 2048x1536 (iPad retina) but lots of transparent pixels around the “core image” but without those transparent pixels restored I cannot align it back to where I had everything. I depend on seeing it full size and in the right location.

I see the sourcewidth/height, and assume that would be use to “reconstruct” the transparent pixels.

[code]
local SheetInfo = {}

SheetInfo.sheet =
{
frames = {

{
– cut
x=8,
y=8,
width=1236,
height=1120,

sourceX = 408,
sourceY = 156,
sourceWidth = 2048,
sourceHeight = 1536
},
},

sheetContentWidth = 1252,
sheetContentHeight = 1136
}

SheetInfo.frameIndex =
{

[“cut”] = 1,
}

function SheetInfo:getSheet()
return self.sheet;
end

function SheetInfo:getFrameIndex(name)
return self.frameIndex[name];
end

return SheetInfo
[/code] [import]uid: 160288 topic_id: 32544 reply_id: 129622[/import]

Another thing, I tried storing the pieces in an imagesheet, when I loaded them via newImage they were too big, when I used newImageRect, it worked perfectly (for the pieces), still can’t get the map working right. [import]uid: 160288 topic_id: 32544 reply_id: 129623[/import]

I might be mistaken, but I believe if you use those last 4 parameters… sourceX, sourceY, sourceWidth, sourceHeight… you’re telling Corona that you actually WANT to trim the sheet and ignore the transparent pixels around. Apparently you don’t want to do that… you want to keep those pixels as part of the overall map, so the positioning works out properly.

Those 4 parameters are totally optional with image sheets. They are useful, and necessary, for ultra-controlled trimming and optimization. But if you want to recognize the sheet with transparent boundaries around, don’t specify them. Again, this is what Texture Packer does “beyond Corona” when you might not actually want that to occur.

Corona offers them because many developers want extreme control over sheet trimming, frame padding, etc… but they remain optional.

Brent [import]uid: 9747 topic_id: 32544 reply_id: 129624[/import]

there are a lot of options w/ texture packer, and it is likely it is something I am picking, I just can’t figure it out. When I select “trim” it adds those in.

If I tell it not to trim/crop, it doesn’t add them, but then again it doesn’t trim the pixels out, and there is no benefit, it is just a full size ipad retina image in an imagesheet. I’m trying to trim the pixels, but bring them back at runtime. Is this possible? If so, what should my imagesheet look like?

Any idea on the second issue? When I don’t use the map in an image sheet and call it directly from 1x/2x/4x I have another problem that looks very much like a Corona bug. All devices look perfect, but the iPad retina shows horizontal stretching but no horizontal stretching but my 4x images are perfect and layout 100% pixel perfect. [import]uid: 160288 topic_id: 32544 reply_id: 129625[/import]

By the way, I did change settings, and tested it previously without sourceheight/width, and it did not change the fact it loads the image content only ignoring all the transparent pixels and made it full screen.

This is without sourceheight/width

http://screencast.com/t/EH6wMAaaenU [import]uid: 160288 topic_id: 32544 reply_id: 129629[/import]

Hi again,
I think this whole scenario has gotten incredibly confusing (sorry) and the solution might be to pull back and simplify. That might be the only way to diagnose where in the process the issue or potential bug is occurring.

I would suggest these steps:

First, create all of your image sheets “equally”. If you have padding around some versions, you must have the same padding (well, scaled in equal proportion) around all versions. I imagine you’re already doing this… no reason to think you’d trim one sheet but not another. For example, if you have a 10-pixel border around your 1x sheet, you need 20 pixels border around the 2x sheet, 40 around the 4x sheet. Again, I know that’s obvious and I’m not trying to be condescending, just pointing out things to check.

Second, try this without TexturePacker, that is essential. I can’t vouch for what TexturePacker is doing… and if it’s doing something weird, then the problem is with some setting there. I’m not suggesting you can NEVER use TexturePacker with this project, just that to diagnose the issue, you have to test without it and implement the image sheet setup in “raw” Corona code.

Use “newImage()” instead of “newImageRect()”… and as another step, pass “true” as the second parameter. This sets the “isFullResolution” flag, which actually shouldn’t be necessary, but it can’t hurt to supply it as true.

By the way, what is this line? It does not appear to be valid code. I noticed it in one of your earlier code blocks, but maybe you’ve corrected it since then.

imgMap.setReferencePoint(imgMap, display.TopLeftReferencePoint)

Best regards,
Brent [import]uid: 9747 topic_id: 32544 reply_id: 129678[/import]

I fixed the reference point, it was a typo. I get confused when to use . and when to use :

All image sheets are created equally. Texture Packer users the same padding for each version along with using common divisor to avoid blurred pixels.

I am not sure if I could do it without texture packer, I would have to align all the images in Photoshop I assume and calculate where all the pieces are. Would be a tremendous about of work for one sheet, unless I am missing something.

I tried newImage() and new image(imageSheet, index, true) and both result in the same thing. The pieces no longer line up and in fact overlap.

local piece = display.newImage(piecesImageSheet, piecesSheetInfo:getFrameIndex(pieces[i].color), display.isFullResolution)

[import]uid: 160288 topic_id: 32544 reply_id: 129681[/import]

Is this the actual line you’re using in code or just an example?

local piece = display.newImage(piecesImageSheet, piecesSheetInfo:getFrameIndex(pieces[i].color), display.isFullResolution)

The difference between “.” and “:” can be confusing, but in general, the dot is used for Lua “object/library properties” (read or declare them), while the colon is used as a Lua “object method”, meaning that you want to affect the item before the colon with the command after it. A strict explanation is more complex than that, of course. :slight_smile: [import]uid: 9747 topic_id: 32544 reply_id: 129683[/import]

I changed my code to that Did I do it wrong?

Also, I am using public build 894, I found this

Build 929
“Fixes casenum: 17866. Sprite trimming regression introduced in build 926.”

I wonder if this is affecting what I am doing. [import]uid: 160288 topic_id: 32544 reply_id: 129684[/import]

It’s probably not the issue, but in this line:

local piece = display.newImage(piecesImageSheet, piecesSheetInfo:getFrameIndex(pieces[i].color), display.isFullResolution)

display.isFullResolution isn’t valid, unless you previously declared it. “isFullResolution” isn’t an inherent property of the display library.

Try this somewhere in your code:

print(display.isFullResolution)

Now look at the Terminal… most likely it will print “nil” in there, which means it’s not a defined or existing property. What you want to enter instead is true.

As for that “sprite regression” issue, it sounds like it was something introduced in Build 926 and fixed shortly after in Build 929… so it wouldn’t affect Build 894. It’s possible there’s another bug (which is what we’re trying to determine), but I don’t think it’s that one in specific.

Brent
[import]uid: 9747 topic_id: 32544 reply_id: 129688[/import]

I tried just “true” and it didn’t make any difference, so I used display.isFullResolution thinking I was suppose to do that instead.

I’m not sure about this trimming, I think this maybe a bug or just something I am doing wrong. The other issue where it stretches one resolution horizontally only but all other resolutions don’t stretch I have a gut feeling is a bug.

Should I just zip up the project and send it to them with notes on what is happening? It is only 160 lines of code right now and most of it is needed so everything can be seen in relationship to each other. I shouldn’t have discussed two issues in this thread, it just makes it more confusing, I am sorry. Should I move the 2nd issue into another thread and keep this just for the trimming issue?
[import]uid: 160288 topic_id: 32544 reply_id: 129689[/import]

Hello,
If you can, please zip up the project and send it to me first. I’m in the middle of several other things, but I might get a chance to look at it this weekend. If not, early next week is likely. If I notice anything weird, maybe I can fix it… if everything looks fine, then it could be a bug and I’ll submit it to Corona.

brent (at) ignisdesign (dot) com

Thanks! [import]uid: 9747 topic_id: 32544 reply_id: 129693[/import]

Thanks, I will shoot you an email shortly.
I just purchased a Pro license of Corona, and downloaded the latest build. It did not affect the re-sizing issue that I believe maybe a bug. It didn’t change anything in regards to the trim issue either. [import]uid: 160288 topic_id: 32544 reply_id: 129694[/import]

Hi again,
I think this whole scenario has gotten incredibly confusing (sorry) and the solution might be to pull back and simplify. That might be the only way to diagnose where in the process the issue or potential bug is occurring.

I would suggest these steps:

First, create all of your image sheets “equally”. If you have padding around some versions, you must have the same padding (well, scaled in equal proportion) around all versions. I imagine you’re already doing this… no reason to think you’d trim one sheet but not another. For example, if you have a 10-pixel border around your 1x sheet, you need 20 pixels border around the 2x sheet, 40 around the 4x sheet. Again, I know that’s obvious and I’m not trying to be condescending, just pointing out things to check.

Second, try this without TexturePacker, that is essential. I can’t vouch for what TexturePacker is doing… and if it’s doing something weird, then the problem is with some setting there. I’m not suggesting you can NEVER use TexturePacker with this project, just that to diagnose the issue, you have to test without it and implement the image sheet setup in “raw” Corona code.

Use “newImage()” instead of “newImageRect()”… and as another step, pass “true” as the second parameter. This sets the “isFullResolution” flag, which actually shouldn’t be necessary, but it can’t hurt to supply it as true.

By the way, what is this line? It does not appear to be valid code. I noticed it in one of your earlier code blocks, but maybe you’ve corrected it since then.

imgMap.setReferencePoint(imgMap, display.TopLeftReferencePoint)

Best regards,
Brent [import]uid: 9747 topic_id: 32544 reply_id: 129678[/import]

I fixed the reference point, it was a typo. I get confused when to use . and when to use :

All image sheets are created equally. Texture Packer users the same padding for each version along with using common divisor to avoid blurred pixels.

I am not sure if I could do it without texture packer, I would have to align all the images in Photoshop I assume and calculate where all the pieces are. Would be a tremendous about of work for one sheet, unless I am missing something.

I tried newImage() and new image(imageSheet, index, true) and both result in the same thing. The pieces no longer line up and in fact overlap.

local piece = display.newImage(piecesImageSheet, piecesSheetInfo:getFrameIndex(pieces[i].color), display.isFullResolution)

[import]uid: 160288 topic_id: 32544 reply_id: 129681[/import]

Is this the actual line you’re using in code or just an example?

local piece = display.newImage(piecesImageSheet, piecesSheetInfo:getFrameIndex(pieces[i].color), display.isFullResolution)

The difference between “.” and “:” can be confusing, but in general, the dot is used for Lua “object/library properties” (read or declare them), while the colon is used as a Lua “object method”, meaning that you want to affect the item before the colon with the command after it. A strict explanation is more complex than that, of course. :slight_smile: [import]uid: 9747 topic_id: 32544 reply_id: 129683[/import]