Sign in to follow this  
J4G

Phaser gaps between scaled tiles

Recommended Posts

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.

 

dTEcgMg.png

 

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.