J4G Posted May 16, 2015 Share Posted May 16, 2015 I'm creating a tile-based game where the game is set to always have ten tiles vertically and scale every tile to fit as such. At certain window sizes, however, there are gaps every few tiles running vertically. Strangely enough these lines only run vertically and not horizontally. I'm assuming this is because of the non-round scaling (a typical number is something like 2.496875). Any ideas how to fix this? Link to comment Share on other sites More sharing options...
Tom Atom Posted May 16, 2015 Share Posted May 16, 2015 How are you drawing your tiles? Are you using Phaser.Tilemep? Tilemap contains TileMapLayers and these are first drawn with scale 1,1 and then scaled, so there should not be this. But if you are placing tiles side by side by yourself then you can run into that issue. If you are not using TileMap I would suggest to make tiles such that it overlaps with 1px in the beginning and in the end. J4G 1 Link to comment Share on other sites More sharing options...
J4G Posted May 16, 2015 Author Share Posted May 16, 2015 I'm not using TileMap, I'm placing them individually. I'm not entirely sure what you're suggesting with the overlap, could you clarify? Currently the placement of the vertical lines changes depending on the scaling of the individual tiles. Link to comment Share on other sites More sharing options...
lewster32 Posted May 16, 2015 Share Posted May 16, 2015 You're correct - this is a scaling (and possibly a positioning) issue. This is the caveat of arbitrarily scaling pixel art - pixels should really be scaled by common multiples or divisors, i.e. half (0.5), double (2), quadruple (4) etc. When working with pixel art you should also really be rounding the position values too or you'll encounter similar issues. If you really must do arbitrary scaling, you may have to ensure your tiles overlap slightly (i.e. if your grid size is 32 pixels, reduce it to 31 pixels so each tile overlaps the previous by 1 pixel) as J4G says, so that the gaps don't appear - your pixel art will still look jagged and weird though, especially when it or the camera moves! J4G 1 Link to comment Share on other sites More sharing options...
J4G Posted May 16, 2015 Author Share Posted May 16, 2015 I ended up just flooring my calculated x value for each tile. It wasn't what I originally intended, but it seems to be working just fine! Link to comment Share on other sites More sharing options...
jgordon510 Posted April 5, 2017 Share Posted April 5, 2017 I had a similar issue, but I wasn't able to get this to work by flooring my x-values. I found that adding this line: Phaser.scaleModes.DEFAULT = 1; Created pixel perfect scaling, akin to Tilemap. elkranio 1 Link to comment Share on other sites More sharing options...
Recommended Posts