(i am creating this because there was some discussion about this on my last topic). I have mac os 10 point something. I would use tiled but that is not supported with my os and upgrading os is not an option. Do you know of any good tile editors that work for mac os 10+ and work well with phaser? sprite fusion would be great, but I do not know how to turn a png or json file into a tilemap.
There’s LDtk but it doesn’t have a native Phaser importer. It can export in Super-Simple or TMX format.
thanks a lot! would I use this.load.tilemap(‘name’, ‘path’);?
I tried this.load.tilemap(‘map’, ‘map.ldtk’) but it did not work. All I see is a black screen, console says this.load.tilemap is not a function. Very confused.
I realized the Tiled export is actually TMX (not JSON) so don’t use that.
I think for LDtk’s Super simple export you would do something like
function preload() {
// the text file containing extra level information and entities.
this.load.json('data', 'data.json');
// one PNG per layer (eg. backgroundLayer.png),
this.load.image('backgroundLayer', 'backgroundLayer.png');
// one CSV per IntGrid layer (eg. collisions.csv). Same data as in the previous PNG, but in a plain-text format.
this.load.tilemapCSV('collisions', 'collisions.csv');
}
function create() {
this.add.image(0, 0, 'backgroundLayer').setOrigin(0, 0);
const map = this.make.tilemap({ key: 'collisions', tileWidth: 32, tileHeight: 32 });
// Empty tileset image because `createLayer()` needs a tileset.
// Size depends on how many indexes are in 'collisions.csv'.
this.textures.addDynamicTexture('tileset', 256, 256);
map.addTilesetImage('tileset');
// Hidden.
const collisionsLayer = map.createLayer(0, map.tilesets).setVisible(false);
collisionsLayer.setCollision(1, true);
// etc.
}
when I did the super simple export, I got one json and 3 png files. I put a png file in the this.load.tilemapCSV code, but now the console says
“TypeError: this.textures.addDynamicTexture is not a function”
If the map doesn’t have an IntGrid layer, I guess there will be no CSV data. Not sure how to do it then.
addDynamicTexture()
is in Phaser v3.60 and later.
Try this importer.
https://github.com/mobilex1122/phaser-ldtk-importer
UPD: It is still under development
this looks a little shady but it probably works.
thanks!