Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Using .js files from tiled


tembac
 Share

Recommended Posts

Hello Everyone,

I noticed that tiled allows to save the map file on .js files. I would like to know if it is posible to use them with phaser and if it has advantages over tmx or json files. I'm only going to use the object layers from tiled so Tilemaps are not important for me at the moment.

An example of the file generated by tiled:
 

(function(name,data){
 if(typeof onTileMapLoaded === 'undefined') {
  if(typeof TileMaps === 'undefined') TileMaps = {};
  TileMaps[name] = data;
 } else {
  onTileMapLoaded(name,data);
 }})("test",
{ "height":25,
 "layers":[
        {
         "draworder":"topdown",
         "height":100,
         "name":"Object Layer 1",
         "objects":[
                {
                 "height":52.2466039707419,
                 "id":3,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":827.949256794968,
                 "x":104.493207941484,
                 "y":353.187042842215
                }, 
                {
                 "gid":1,
                 "height":36,
                 "id":5,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":32,
                 "x":291.210031347962,
                 "y":285.502612330199
                }, 
                {
                 "gid":1,
                 "height":36,
                 "id":6,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":32,
                 "x":362.619153674833,
                 "y":289.714922048998
                }, 
                {
                 "gid":1,
                 "height":36,
                 "id":7,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":32,
                 "x":422.010393466964,
                 "y":291.199703043801
                }, 
                {
                 "gid":1,
                 "height":36,
                 "id":8,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":32,
                 "x":496.249443207127,
                 "y":271.897550111359
                }, 
                {
                 "gid":1,
                 "height":36,
                 "id":9,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":32,
                 "x":555.640682999258,
                 "y":268.927988121752
                }, 
                {
                 "gid":1,
                 "height":36,
                 "id":10,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":32,
                 "x":613.547141796585,
                 "y":309.01707498144
                }, 
                {
                 "gid":2,
                 "height":134,
                 "id":11,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":128,
                 "x":675.420935412027,
                 "y":300.110616184113
                }, 
                {
                 "gid":2,
                 "height":134,
                 "id":12,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":128,
                 "x":151.293244246474,
                 "y":306.049740163326
                }, 
                {
                 "height":34.1499628804751,
                 "id":13,
                 "name":"",
                 "rotation":0,
                 "type":"",
                 "visible":true,
                 "width":498.886414253898,
                 "x":1135.8574610245,
                 "y":357.832219747587
                }],
         "opacity":1,
         "type":"objectgroup",
         "visible":true,
         "width":100,
         "x":0,
         "y":0
        }],
 "nextobjectid":14,
 "orientation":"orthogonal",
 "renderorder":"right-down",
 "tileheight":32,
 "tilesets":[
        {
         "columns":0,
         "firstgid":1,
         "margin":0,
         "name":"Objects",
         "spacing":0,
         "tilecount":2,
         "tileheight":134,
         "tiles":
            {
             "0":
                {
                 "image":"..\/images\/cassettes.png"
                },
             "1":
                {
                 "image":"..\/images\/Enemy.png"
                }
            },
         "tilewidth":128
        }],
 "tilewidth":32,
 "version":1,
 "width":100
});

 

Link to comment
Share on other sites

Well, this looks like the JSON that Phaser would load for you anyway, except it's in a global object called Tilemaps (unless you defined an onTileMapLoaded handler). I don't see much difference between the two approaches other than you don't have to load JSON in the loader... but that's not such a great benefit because I imagine the JSON files are pretty lightweight compared to graphics and sound files.

Link to comment
Share on other sites

  • 2 weeks later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...