1. Home
  2. Docs
  3. LEd documentation
  4. JSON
  5. JSON “levels” section

JSON “levels” section

The levels field in the root of the JSON contains most important data for game devs :)

Each level contains an array of layerInstances that look like this:

"layerInstances": [
	{
		"__identifier": "IntGrid",
		"__type": "IntGrid",
		"__cWid": 16, // layer width (grid based)
		"__cHei": 16, // layer height (grid based)
		"__gridSize": 16,
		"levelId": 0,
		"layerDefUid": 1,
		"pxOffsetX": 0, // optional offset that could happen when resizing levels
		"pxOffsetY": 0, // same
		"seed": 7382459,
		"intGrid": [], // only populated if layer is an IntGrid
		"autoTiles": [], // only populated if layer is an Auto-layer
		"gridTiles": [], // only populated if layer is a TileLayer
		"entityInstances": [] // only populated if layer is an EntityLayer
	}
]

Layers

IntGrid layer instances

"intGrid": [
	{ "coordId": 50, "v": 0 }, 
	{ "coordId": 51, "v": 1 },
	{ "coordId": 52, "v": 0 },
	{ "coordId": 66, "v": 0 },
	{ "coordId": 67, "v": 0 },
	{ "coordId": 68, "v": 0 }
	...
]

The intGrid array contains coordinate IDs associated with the Integer value stored there.

Auto-layer instances

When an IntGrid layer has a linked Tileset, it will have its autoTiles field populated:

"autoTiles": [
	{
		"ruleId": 101,
		"results": [ {
			"coordId": 90,
			"tiles": [
				{ "tileId": 169, "__xOff": 0, "__yOff": -8, "__srcX": 8, "__srcY": 112 },
				{ "tileId": 181, "__xOff": 0, "__yOff": 0, "__srcX": 8, "__srcY": 120 }
			],
			"flips": 0
		} ]
	}
]

The autoTiles array contains each auto-layer Rule result. A rule result is simply of array of tiles (tileIds) that were generated because of it.

The tileIds work pretty much like coordinate IDs (with the added complexity of padding/spacing options): they refer to a grid coordinate in the tileset atlas image.

But to make your life easier, you will also get the __srcX and __srcY values that point to pixel coordinates in the tileset atlas image ;)

Each tile can be optionally transformed using symmetry, as stored in the flips value:

  • flips:0 : no transformation
  • flips:1 : horizontal (X) symmetry
  • flips:2 : vertical (Y) symmetry
  • flips:3 : both horizontal (X) and vertical (Y) symmetries

Note: you might notice that flips is actually a 2-bits value : 1st bit represents X symmetry and 2nd bit represents Y symmetry.

Tile layer instances

"gridTiles": [
	{ "coordId": 55, "tileId": 15, "__x": 224, "__y": 96, "__srcX": 96, "__srcY": 64 },
	{ "coordId": 56, "tileId": 15, "__x": 256, "__y": 96, "__srcX": 96, "__srcY": 64 },
	{ "coordId": 65, "tileId": 11, "__x": 32, "__y": 128, "__srcX": 160, "__srcY": 32 },
	{ "coordId": 71, "tileId": 15, "__x": 224, "__y": 128, "__srcX": 96, "__srcY": 64 },
	{ "coordId": 72, "tileId": 15, "__x": 256, "__y": 128, "__srcX": 96, "__srcY": 64 },
	{ "coordId": 81, "tileId": 17, "__x": 32, "__y": 160, "__srcX": 160, "__srcY": 64 }
}

The gridTiles array contains all the tileIds (tileset image coordinate) with their corresponding coordId (layer coordinate). You can use the __x and __y which are pixel coordinates of tiles on screen.

To make your life easier, you also get the pixel coordinates of the tiles in the tileset image from __srcX and __srcY.

Entity layer instances

"entityInstances": [ 
	{ 
		"__identifier": "Enemy", 
		"__cx": 24, 
		"__cy": 7, 
		"defUid": 1, 
		"x": 196, 
		"y": 64, 
		"fieldInstances": [
			{
				"__identifier": "loots",
				"__value": [ "Healling_potion", "Trout" ],
				"__type": "Array<LocalEnum.Item>",
				"defUid": 4,
				"realEditorValues": [ {
					"id": "V_String",
					"params": [ "Healling_potion" ]
				}, {
					"id": "V_String",
					"params": [ "Trout" ]
				} ]
			}
		]
	}
]

The entityInstances array contains every entities attached in the current layer. Each entity can have a variety of custom fields, as filled in the editor. Each field is stored in the fieldInstances array.

The actual “easy to parse” value is stored in __value. Its type varies, based on the field type. See some examples below.

Note: if your field is, for example, an Integer limited to [1,5] range, and no value was manually provided in the editor, the __value field will be 1, to always comply with your field definitions.

Integer / Float / Bool / String fields

{
	"__identifier": "life",
	"__value": 3, 
	"__type": "Int",
	"defUid": 2,
	"realEditorValues": [ /* you shouldn't care about this internal thing */ ]
}

Color fields

{
	"__identifier": "hairColor",
	"__value": "#FF0000",
	"__type": "Color",
	"defUid": 58,
	"realEditorValues": [ /* only for the editor */ ]
}

Enums

{
	"__identifier": "enemyType",
	"__value": "Fighter",
	"__type": "LocalEnum.MonsterType",
	"defUid": 49,
	"realEditorValues": [ /* no one reads that anyway */ ]
}

Arrays

Arrays of values work exactly the same for all types described above, except… well they are arrays.

{
	"__identifier": "colors",
	"__value": [ "#FF0000", "#00FF00", "#0000FF" ],
	"__type": "Array<Color>",
	"defUid": 53,
	"realEditorValues": [ /* don't care */ ]
}