Open
Description
Version
- Phaser Version: 3.80.1
- Operating system: Windows 11
- Browser: Edge
Description
I wanted to create the tilemap objects myself and copied logic from here
But the positions of the objects were not correct
I created a new map and got exactly the same result with createFromObjects
Example Test Code
const tilemap = this.add.tilemap(Timemaps.test);
const tile_grass = tilemap.addTilesetImage('tile_grass', Images.tile_grass)!;
tilemap.createLayer('Tile Layer 1', tile_grass);
tilemap.createFromObjects('Object Layer 1', {
gid: 2,
key: Images.marker
});
Tiled JSON
{
"compressionlevel": -1,
"height": 4,
"infinite": false,
"layers": [
{
"data": [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
],
"height": 4,
"id": 1,
"name": "Tile Layer 1",
"opacity": 1,
"type": "tilelayer",
"visible": true,
"width": 4,
"x": 0,
"y": 0
},
{
"draworder": "topdown",
"id": 2,
"name": "Object Layer 1",
"objects": [
{
"gid": 2,
"height": 40,
"id": 1,
"name": "",
"rotation": 0,
"type": "",
"visible": true,
"width": 40,
"x": 178.41935483871,
"y": 179.58064516129
}
],
"opacity": 1,
"type": "objectgroup",
"visible": true,
"x": 0,
"y": 0
}
],
"nextlayerid": 3,
"nextobjectid": 2,
"orientation": "isometric",
"renderorder": "right-down",
"tiledversion": "1.10.2",
"tileheight": 108,
"tilesets": [
{
"columns": 1,
"firstgid": 1,
"image": "tile_grass.png",
"imageheight": 108,
"imagewidth": 186,
"margin": 0,
"name": "tile_grass",
"spacing": 0,
"tilecount": 1,
"tileheight": 108,
"tilewidth": 186
},
{
"columns": 0,
"firstgid": 2,
"grid": {
"height": 1,
"orientation": "orthogonal",
"width": 1
},
"margin": 0,
"name": "marker",
"spacing": 0,
"tilecount": 1,
"tileheight": 40,
"tiles": [
{
"id": 0,
"image": "marker.png",
"imageheight": 40,
"imagewidth": 40
}
],
"tilewidth": 40
}
],
"tilewidth": 186,
"type": "map",
"version": "1.10",
"width": 4
}