1. Home
  2. Game dev
  3. JSON overview
  4. Coordinate IDs

Coordinate IDs

Some layers use coordIds to store their data. A coordId is always the result of the following formula:

var coordId = gridBasedX + gridBasedY * gridBasedWidth;

This means that you can get gridBasedY from a coordId like this:

var gridBasedY = Math.floor( coordId / gridBasedWidth );
var gridBasedX = coordId - gridBasedY * gridBasedWidth

Please note that grid based values are usually prefixed with a c:

  • cx/cy for a grid based X/Y
  • cWid/cHei for a grid based width/height