neon Posted February 6, 2015 Share Posted February 6, 2015 Hey, I was just wondering. In the docs under "addTilesetImage" there is written that one can use multiple tilesets for the same map. But how do you select which tileset is currently in use? I can't find any function and there is no example with multiple tilesets.Everytime i load two or more tileset images, only tiles from the first are used. There is a thread about the same topic, but without an answer:http://www.html5gamedevs.com/topic/8266-use-multiple-tileset-images-in-one-tilemap/ So is there a way to use multiple tilesets like it's written in the docs? Edit:There is an example with multiple tilesets: http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=create+from+objects.js&t=create%20from%20objects but i uses tiled json. I need to specify the map dynamically in code Edit2:Ok, i probably got that you can't have multiple tilesets per map. You can have only one set per layer. For changing tileset I needed to clear the cache after every change with resetTilesetCache. Link to comment Share on other sites More sharing options...
valueerror Posted February 8, 2015 Share Posted February 8, 2015 i always use multiple tilesets in one map.. i just add all of them in tiled and then in my code.. no tricks needed... http://test.xapient.net/phaser/hills/ in this example i just uploaded for another user i use two tilesets .. test-tileset and ice-terrain Link to comment Share on other sites More sharing options...
P4nch0 Posted December 13, 2015 Share Posted December 13, 2015 hi, I have the same problem. Can You show me how to use methods resettilecache? I need to chose tileset wich will be use when i am addind tile to the game, and dont know how. Link to comment Share on other sites More sharing options...
ezThanh Posted November 13, 2016 Share Posted November 13, 2016 On 2/7/2015 at 4:47 AM, neon said: Hey, I was just wondering. In the docs under "addTilesetImage" there is written that one can use multiple tilesets for the same map. But how do you select which tileset is currently in use? I can't find any function and there is no example with multiple tilesets. Everytime i load two or more tileset images, only tiles from the first are used. There is a thread about the same topic, but without an answer: http://www.html5gamedevs.com/topic/8266-use-multiple-tileset-images-in-one-tilemap/ So is there a way to use multiple tilesets like it's written in the docs? Edit: There is an example with multiple tilesets: http://examples.phaser.io/_site/view_full.html?d=tilemaps&f=create+from+objects.js&t=create%20from%20objects but i uses tiled json. I need to specify the map dynamically in code Edit2: Ok, i probably got that you can't have multiple tilesets per map. You can have only one set per layer. For changing tileset I needed to clear the cache after every change with resetTilesetCache. I just found out you need to change map.tiles array. Which is used for drawing tile into tile map. Here is my code for doing that. You need to do it every time you change your tile set. There is one problem thought, i think you need to clear it tile set cache too var changeMapTileSetArray = function(tileSetKey){ map.tiles = []; var tileSet = Constant.TILE_SET_DICT[tileSetKey]; var currentTileSetId = map.getTilesetIndex(tileSetKey); for(var i = 0;i<tileSet.tileList.length;i++){ map.tiles.push([tileSet.tileList[i].x,tileSet.tileList[i].y,currentTileSetId]); } }; Link to comment Share on other sites More sharing options...
Recommended Posts