Sprites not properly cut occasionally

Hi everyone!

I’m almost done with my app and am now getting to the small bugs.  I have absolutely no space between my sprites I have in a row in a spritesheet.  They literally touch pixel to pixel.  Now this should work fine, as I can specify the exact width and height of the items in there (they are all exactly the same). Most of the time this works, but sometimes it makes a mistake, and I can see a little line from an adjacent frame.

Any ideas why this might be happening, and why it would only happen sometimes and not others?

Hi @hdtruelson,

It’s not uncommon to get “bleed” from adjacent frames when your sprites are touching pixel-to-pixel. This is a behavior of OpenGL. Generally, you should pad your sprites with 2-3 pixels on all sides. Did you use a packing utility like TexturePacker to assemble your sheets, or did you create them manually? TexturePacker has a built-in feature to add padding around frames, so if you used that, it should be relatively easy to rebuild your sheets and then update your code to utilize that padding.

Best regards,

Brent

I see, I did pack them manually.  Is there a way to specify padding using this format:

local options = { width = 100, height = 100, numFrames = 10, sheetContentWidth = 1000, --width of original 1x size of entire sheet sheetContentHeight = 1000 --height of original 1x size of entire sheet }

Or do I need to use the more complex one?

Hi again,

You’ll need to re-pack them, unfortunately, with some padding between frames. Well, you could define slightly smaller frames in your code (using the “complex” frame setup) but then you’d lose some frame content.

Brent

Hi @hdtruelson,

It’s not uncommon to get “bleed” from adjacent frames when your sprites are touching pixel-to-pixel. This is a behavior of OpenGL. Generally, you should pad your sprites with 2-3 pixels on all sides. Did you use a packing utility like TexturePacker to assemble your sheets, or did you create them manually? TexturePacker has a built-in feature to add padding around frames, so if you used that, it should be relatively easy to rebuild your sheets and then update your code to utilize that padding.

Best regards,

Brent

I see, I did pack them manually.  Is there a way to specify padding using this format:

local options = { width = 100, height = 100, numFrames = 10, sheetContentWidth = 1000, --width of original 1x size of entire sheet sheetContentHeight = 1000 --height of original 1x size of entire sheet }

Or do I need to use the more complex one?

Hi again,

You’ll need to re-pack them, unfortunately, with some padding between frames. Well, you could define slightly smaller frames in your code (using the “complex” frame setup) but then you’d lose some frame content.

Brent