0

I create simple RPG game on Android use Monogame and Xamarin and I have problem with tiles.

I use tiles 16x16 but I scale it to 32x32, I create simple Map Editor, I can create maps and convert to JSON format.

But after load map in game I see lines between tiles, These lines show where the object should be slightly transparent https://i.stack.imgur.com/ShN4A.png

Load Map

            using (var stream = TitleContainer.OpenStream(path2))
            {
                spriteSheet2 = Texture2D.FromStream(graphicsDevice, stream);
            }
            currSprite = 2;
            for (int y = 0; y < spriteSheet2.Height; y += 32 + 2)
            {
                for (int x = 0; x < spriteSheet2.Width; x += 32 + 2)
                {
                    objects[currSprite].Add(new Rectangle(x, y, 32, 32));

                }
            }

            using (var stream = TitleContainer.OpenStream("Content/x.png"))
            {
                test = Texture2D.FromStream(graphicsDevice, stream);
            }

I debug it and use GIMP, in spritesheet anywhere these it lines In map editor I didn't see this lines, how I can fix it? I have this same code to load spritesheet in Map Editor and in game, in spritesheet I have 2px margin beetwen tiles.

(I must create album with images, because I can't give more than two links) https://i.stack.imgur.com/uSIwg.jpg

Image after change margin in code to 1px (See, first image in album)

Image after change tiles size to 31x31 (See, second image in album)

I get position floor tiles in spritesheet and use gimp I checked if the margins are too small, I zoom to this tile (See, third image in album)

I can eliminate white-lines when I set rectangle floor tile to 273, 69 and change size to 30, 30 (it's position rectangle without transparent lines in tile, but why transparent line have white color in game?) (See, last image in album)

I fix floor by eliminate transparent from tile, how I can fast fix it for all tiles?

Cœur
  • 37,241
  • 25
  • 195
  • 267
thebox
  • 3
  • 2

1 Answers1

0

Your code is good I watch the problem, your sprites have a transparency in the border. If you wanna delete all lines in tile sprites you need edit the sprites and replace de border with a solid color.

transparency in the border

regards

  • Is any way to fast replace this borders? I have 1700 tiles : – thebox Aug 17 '16 at 10:23
  • you can try to ignore the edge while rendering the sprite X and Y start in 1 and the Height -1 and Width -1 – Marcos José Pérez Pérez Aug 17 '16 at 10:41
  • You solved my problem, actually I search any way to fast remove this borders – thebox Aug 17 '16 at 11:01
  • In 16x16 spritesheet I don't have transparent borders, how I can scale it to 32x32 without this borders? – thebox Aug 17 '16 at 11:13
  • with photoshop you can expand a Image but you need to probe I think you pixelate the image if expand. If you wanna send me the image. Or the link upload to the cloud and send me the link, to edit and see what is the result. or try you to ignore the edge while rendering the sprite X and Y start in 1 and the Height -1 and Width -1 this is the way more fast. – Marcos José Pérez Pérez Aug 17 '16 at 11:16
  • I try ignore edge while rendering, but after this I get black-lines beetwen tiles, my tiles is from opengameart if you can try scale this to 32x32 without borders I will be grateful (http://kenney.nl/assets/roguelike-rpg-pack) – thebox Aug 17 '16 at 11:37
  • Or last way is use 16x16 tiles and create zoom in game – thebox Aug 17 '16 at 11:43
  • Is a option or try to search other sprites. – Marcos José Pérez Pérez Aug 17 '16 at 11:58