Random 1-2px gaps when placing PNGs

Alright, I'm trying to place a bunch of little tiles to create an isometric looking map, and it's just killing me at the moment that I randomly (my map is all random generated) I get 1-2px gaps between my tiles :(

For example, here is a "good" placement (but the connector is broken):

Here is a "almost good" placement:

And here is a "bad" placement:

Does anyone have any idea why this could be happening? I can constantly refresh and get a new map in game, and sometimes it renders perfectly on emulator, other times, you get the artifacts like above.

I have no division happening when calculating the tile co-ordinates on screen, so I don't think it should be a rounding error anywhere...

Are all your tile image dimensions--whether you're using spritesheets or not--in even numbers?

No spritesheet here (only two tile images for now).

And no, no they are not. The image is 36x23.. could that be the cause? I'll play around with getting even numbers next

Sometimes when you have an odd-number dimension with any of your resources, they will misalign by a pixel or so... try making sure all of your images have even number dimensions and it should fix your problem.

Also, if you are using @2x resources, make sure your both your @1x and @2x resources also have even number dimensions (you may have to do some playing around with your @2x dimension to get it just right).

Also, when you have odd-number dimensions ... sometimes resources come out slightly blurry, so it's always good to make sure your resources have even dimensions.

Thank you for the notes. Does it matter if the image contents line up with even numbers or is it really just the dimensions that matter?

Just the dimensions on the actual resources matter.

I tried setting the image height to 36x24 (from 36x23) but still running into the same issues (although I want to say less, however that's purely sujective).

I'll just try cheating by changing the image contents to force overlap :(

*EDIT*

GRRR. I extended the white area in each tile to try to force overlap, and it STILL happens. I have no idea what Corona is doing here. These exact tiles and this exact logic works perfectly on XNA.

Figured it out. It was a combination of sometimes getting a float return out of one of my functions _and_ the image height.

Thanks for that pointer, it was key!

views:1403 update:2011/10/3 8:06:12
corona forums © 2003-2011