Cell coordinates in .tilemap file do not match editor

Hello! I am new to Defold but have gone through some tutorials and am enjoying it so far.

I have searched and not found an answer for this: Why do coordinates in a .tilemap file (created in Defold) not match the coordinates shown in the tilemap editor?

I recreated a simple example to illustrate this:

image

tile_set: "/main/map.tilesource"
layers {
  id: "layer1"
  z: 0.0
  is_visible: 1
  cell {
    x: 0
    y: -1
    tile: 29
    h_flip: 0
    v_flip: 0
    rotate90: 0
  }
  cell {
    x: -1
    y: -1
    tile: 29
    h_flip: 0
    v_flip: 0
    rotate90: 0
  }
  cell {
    x: 0
    y: 0
    tile: 158
    h_flip: 0
    v_flip: 0
    rotate90: 0
  }
  cell {
    x: -1
    y: 0
    tile: 29
    h_flip: 0
    v_flip: 0
    rotate90: 0
  }
}
material: "/builtins/materials/tile_map.material"
blend_mode: BLEND_MODE_ALPHA

As you can see, the cells in the .tilemap file are not representative of what is seen in the editor.

Examples:

  • 1,1 in the editor is saved as 0,0 in the file
  • 1,1 doesn’t even exist in the file

I am sure I am missing something simple, and I may have been looking for the answer in the wrong docs, but any help is appreciated!

I believe it is because we adjust the index at runtime in the Lua API to adhere to the 1-indexed nature of Lua, while internally in the engine we use 0 indexed tilemap coordinates.

1 Like

Makes sense. At least now I can compensate for this knowing that it is not abnormal behavior.

Thank you for the response.

1 Like