- Home /
Lines between tiles (tk2d)
Hey,
I create a 2D iPhone game and use image-tiles (160x160px, anchored at the bottom left corner) to fill my screen. The tiles are at a fix position. The first tile is for example at x:0 y:0 and ends at x: 160 y:160, the second starts at 160 / 160 and ends at 320x320 and so on... I move my cam over these tiles and it looks pretty perfect - only at the monitor.. Well.. when I test my App on an iPhone (4, 4s) or an iPad (1, 2), i see lines / borders between the tiles. I testet, if my cam has a float-position, but it hasn't...
Can anyone tell me why this happens (an looks fine on a pc?)?
PS: I use the tk2d spritemanager, I used EZ-GUI before, but in my opinion the performance is not very good...
Greetings, Bregner
Could be a product of aliasing or any number of things. Post some screen shots from both environments.
Answer by ScroodgeM · Sep 05, 2012 at 06:46 PM
disable mipmapping for texture(s) used for tiles. to make 'em look good with mipmapping, you should understand a little what is it and make some extra borders on tiles
Mip Maps are a list of progressively smaller versions of an image, used to optimise performance on real-time 3D engines. Objects that are far away from the camera use the smaller texture versions. Using mip maps uses 33% more memory, but not using them can be a huge performance loss. You should always use mipmaps for in-game textures; the only exceptions are textures that will never be minified (e.g. GUI textures).
imagine that your atlas with tile has some 2x2 piece of pixels like this:
BB BT
B is black pixel and T is tile pixel. in game only T pixel is used for tile model. but, when you tile is far enough, next mipmap level is activated. on next mipmap level your 2x2 pixels are blended into one with value of
0.75B+0.25T
and it is still used on your tile model. of course, it will look darker a little and on the tile border you'll see a black line.
to avoid this you need to disable mipmaps (not recommended if your tiles can be very far rom camera) or make some extra borders with tile's color
Answer by Bregnar · Sep 06, 2012 at 10:00 AM
Problem solved. Well.. it was really simple .... My cam-pos had floats as position.. now I just use int and it works perfect... I was casting my floats to int before posting my problem - but I had a acceleration-method which used Mathf.Lerp and I havn't realized, that (most) floats are the result of this method (doh)... I just wrote a method which makes a nice acceleration without floats...
Answer by christoffer.enedahl.hellothere · Nov 28, 2013 at 01:04 PM
Using Pad method: Extend for the tiled sprite solved it for me. You set it up in the SpriteCollection Editor, click on the tiled sprite and choose Extend in the Pad method dropdown. Click commit.
Answer by spencerj921 · Mar 03, 2014 at 10:53 PM
What fixed it for me is setting the compression for my 2D spritesheet to point instead of bi-linear