hi all,
I’m trying to load a TileMap (generated in Tiled) and display the image/sprite in phaser.
However, The position of the image seems to be not aligned with the tilemap layer.
Any hints what I’m missing?
here is a very simple setup (codepen below):
- default phaser setup, using matter hysics without collisions or gravity
- tilemap is generated form a 20x20 pixel black square, each pixel is a tile
- tilemap image: https://www.benzahler.ch/codepen/blacktest20x20.png
- tilemap json: https://www.benzahler.ch/codepen/blacktest20x20.json
This is how I add the tilemap:
var dictTileMap = this.make.tilemap({key: 'blacktiles'});
var dictImage = dictTileMap.addTilesetImage('blacktiles');
var dictLayer = dictTileMap.createLayer('Tile Layer 1', dictImage, 10,10);
console.log(dictLayer.getBounds());
I’m placing the tilemap layer at coordinates 10/10, while does position the tilemap layer in the top left corner as you can see from the console.log.
However, the image is 10px off both horizontally and vertically.
O have created a pen to demonstrate this:
Any help on how to align image/and layer is greatly appreciated!