Gongreg Posted February 22, 2014 Share Posted February 22, 2014 Hello, I've been enjoying this framework, till I got into one thing - tilemaps.First of all, i want to create a tilemap from array (as I know one of the ways is to export array to csv and the give csv to the tilemap). so i can use this code:game.load.tilemap('fog', null, fog.toCsv(), Phaser.Tilemap.CSV);The tiles will be of 2 types - empty or black. So I only need one image (black.png for example). In earlies versions I saw something like game.load.tileset, but it's no longer there. so now I'm sitting with this code, and I have no idea what to do next: fog.tilemap = game.add.tilemap('fog'); /** * Dunno what to do here */ //fog.tilemap.addTilesetImage('Desert','tile'); var layer = map.createLayer('fog');How can I give the tileset with black image for the tilemap. I don't want to use the json file, since the maps will be dynamic, also i find the json in tilemap examples look really strange. Link to comment Share on other sites More sharing options...
SteveB Posted February 24, 2014 Share Posted February 24, 2014 I've got the same issue although I'm creating a tilemap from JSON. My code was based on the examples that use game.load.tileset but that doesn't seem to be anywhere. Anyone know the correct way of loading the tileset? I saw in another post someone using game.load.image but that doesn't allow the margins to be set. Link to comment Share on other sites More sharing options...
SteveB Posted February 25, 2014 Share Posted February 25, 2014 I should have looked at the source a bit more carefully. The old swaptiles example at http://gametest.mobi/phaser/examples/_site/view_full.html?d=tilemaps&f=swap+tiles.js&t=swap%20tiles has:game.load.tilemap('desert', 'assets/maps/desert.json', null, Phaser.Tilemap.TILED_JSON);game.load.tileset('tiles', 'assets/tiles/tmw_desert_spacing.png', 32, 32, -1, 1, 1);the latest source at https://github.com/photonstorm/phaser/blob/master/examples/tilemaps/swap%20tiles.js has:game.load.tilemap('desert', 'assets/tilemaps/maps/desert.json', null, Phaser.Tilemap.TILED_JSON);game.load.image('tiles', 'assets/tilemaps/tiles/tmw_desert_spacing.png');So I reckon just change to load.image. I presume that the new tilemap picks up margins from the map definition rather than what would have been the tileset. I haven't tried this yet as I not at my dev. PC. Link to comment Share on other sites More sharing options...
Recommended Posts