How can I be sure that the tileset used in making a Tiled map remains as a multiple of 2, since this is a requirement of phaser when loading JSON tiled maps? I have tileset images which I got for free and they are not exactly up to phaser specs to be used.
1 Answer
\$\begingroup\$
\$\endgroup\$
2
You're probably referring to this:
// May be fractional values
var rowCount = (imageHeight - this.tileMargin * 2 + this.tileSpacing) / (this.tileHeight + this.tileSpacing);
var colCount = (imageWidth - this.tileMargin * 2 + this.tileSpacing) / (this.tileWidth + this.tileSpacing);
if (rowCount % 1 !== 0 || colCount % 1 !== 0)
{
console.warn("Phaser.Tileset - " + this.name + " image tile area is not an even multiple of tile size");
}
- It's not a requirement, it's only a console warning
- If you inspect the code carefully (
rowCount % 1
), what it's trying to do is actually check that the tileset dimensions is divisible by the tile size, and not about "even numbers", i.e. divisible by 2
So for example, if your tile size was 32x32 and your tileset image was 64x64, that's ok (32 divides into 64), but if the tileset image was 65x65, that's 1px left over and 65 doesn't divide evenly into 32.
-
\$\begingroup\$ Right, and thanks for your answer. However it does prevent the map from being loaded. \$\endgroup\$ Commented Mar 20, 2017 at 15:19
-
\$\begingroup\$ I believe the WebGL 1.0 specs do require that images be power-of-2, so it might be that way for compatibility. \$\endgroup\$– JayCommented Apr 17, 2019 at 23:09