1. Home
  2. Game dev
  3. JSON overview
  4. Layer instances

Layer instances

Each level always contains a layer instance for each layer definition found in defs. Each layer instance might contain specific data, depending on its actual type. Please refer to the Json schema for more information.

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.

Tile layer instances

"gridTiles": [
    { "px": [80,32], "src": [0,0], "f": 0, "d": [37,0] },
    { "px": [96,32], "src": [16,0], "f": 0, "d": [38,1] },
    { "px": [80,48], "src": [0,16], "f": 0, "d": [53,20] },
    { "px": [96,48], "src": [16,16], "f": 0, "d": [54,21] }
],

The gridTiles array contains all the tiles in display order (1st one is beneath 2nd one, etc.).

Each tile has:

  • px: Pixel coordinates of the tile in the layer (array format [x,y]). Don’t forget optional layer offsets, if they exist!
  • src: Pixel coordinates of the tile in the tileset ([x,y] format)
  • f: “Flip bits”, a 2-bits integer to represent the mirror transformations of the tile. Bit 0 is X symmetry and bit 1 is Y symmetry. So you get the following possible values:
    • f=0 : no transformation
    • f=1 : horizontal (X) symmetry
    • f=2 : vertical (Y) symmetry
    • f=3 : both horizontal (X) and vertical (Y) symmetries

Auto-layer instances

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

"autoLayerTiles": [
    { "px": [48,48], "src": [0,112], "f": 0, "d": [5,51,140] },
    { "px": [64,48], "src": [0,112], "f": 0, "d": [5,52,140] },
    { "px": [48,64], "src": [0,112], "f": 0, "d": [5,67,140] },
    { "px": [64,64], "src": [0,112], "f": 0, "d": [5,68,140] }
],

See Tile Layer instances above for an explanation of these values.

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. See Entity fields for more information.