Search the Community
Showing results for tags 'tilemap csv layer'.
-
I've just started with phaser and I'm looking into csv tile maps. I'm using tiled to create the maps with multiple layers to separate parts of the map such as collision, npc, etc. Exporting the map to csv leads to multiple csv files being created which is what im unsure on how to handle with phaser. To get around this i've combined the layers before exporting them however this is not ideal as I would prefer less coupling. A problem that I have faced is that i'm not sure how to add and reference multiple csv tile layers to a game based on the phaser documentation. Reference: https://phaser.io/examples/v2/tilemaps/csv-map Q1. Why is the parameter passed in 0 when creating a layer based on the csv tiles? layer = map.createLayer(0); Q2. How would I go about adding in a second layer so that it's part of the same map and is shown at the same time as the first layer? function preload() { game.load.tilemap('map', 'assets/tilemaps/csv/catastrophi_level1.csv', null, Phaser.Tilemap.CSV); game.load.tilemap('map2', 'assets/tilemaps/csv/catastrophi_level2.csv', null, Phaser.Tilemap.CSV); game.load.image('tiles', 'assets/tilemaps/tiles/catastrophi_tiles_16.png'); game.load.image('tiles2', 'assets/tilemaps/tiles/catastrophi_tiles_16.png'); } var map; var layer; var cursors; function create() { // Because we're loading CSV map data we have to specify the tile size here or we can't render it map = game.add.tilemap('map', 16, 16); // Now add in the tileset map.addTilesetImage('tiles'); // Create our layer layer = map.createLayer(0); map2 = game.add.tilemap('map2', 16, 16); map2.addTilesetImage('tiles'); layer2 = map2.createLayer(?);// 0? map.layers.push(layer2);//make sure both layers are on the same map?