TMX and JSON Object data doesn't seem to match

Hello, I was working with the JSON format trying to create physics bodies from the Tile Collision Editor. I was having a difficult time trying to figure out how to get the correct positions for the polyline since it always starts a (0, 0). I noticed in the TMX file, the Object contains an x and y value that I should use as the starting position to add to the polyline point values. However, the Object x and y information is not in the JSON export, making it impossible to get the correct positions of the polylines. Here is an example of the data I’m seeing. Perhaps, Im missing something?


<tile id="54" terrain=",,,5">
 <image width="64" height="64" source="tiles@1x/IronMinesTerrain-54.png"/>
 <objectgroup draworder="index">
  <object id="0" x="63.8813" y="33.2256">
   <polyline points="0,0 -28.82,-0.183567 -28.82,30.8393"/>


  "terrain":[-1, -1, -1, 5]

Thanks for your help!

The x and y properties seem to be missing because your object has an ID of 0, which normally indicates it is an object template, for which the position is not saved.

I could not immediately reproduce this problem. So the question is, how did you manage to create an object that didn’t get a valid ID assigned to it? And which version of Tiled are you using?

Ah it’s probably because I initially created my tiles “Based on a Tileset Image”, but decided to move to a “Collection of Images”. In order to keep my file tiles the same and not have to recreate the layout, I deleted the original “Tileset Image” tileset, then changed the new “Collection of Images” firstgid to be what the original set was.

Something must have went weird along the way.

Is there a way to replace a Tileset with another?

Version is 1.2.3

Could it be because I initially created the tileset in 0.14.2?

It seems when I use that to create the tile sets, the objects have an ID of 0.

Ill try to recreate the tile sets with 1.2.3 and see if that fixes the issue.

Thanks for you help!

That could be, because I fixed saving of object IDs assigned to tile collision shapes in Tiled 0.16.1.

But opening such a tileset in a more recent Tiled version should assign valid IDs to those objects. If it doesn’t do that then I’ll need to look into fixing it.

Well, it indeed doesn’t assign valid IDs, except on a per-tile basis when you would edit its collision shapes. Due to the way the allocation of IDs is implemented this is not so easy to change, so instead I opted to fix the saving of the position by adjusting the condition that suppressed it:

Thanks bjorn!

Is there a way I can use this updated version of Tiled? Do I need to wait for a release, or is there another way I can install it?

If not, not worries, as I was able to just assign a value of 1 to the ID where it was 0 before and it seems to work fine, albeit a bit of a hack :wink:

Thanks again!

The fix will be included in a future Tiled 1.2.4 release as well as in the next development snapshot. I expect it will take about a week until I’ll do another snapshot and/or the release.

That said, for some platforms builds are temporarily available based on each commit. If you’re on Windows for example, you can find a build including this particular fix at AppVeyor (unfortunately it seems the 64-bit build failed due to a network error).