Search code examples
tiledcocoscreator

How to access TiledMap object's type or a custom property that's specified in Tiled Editor?


How can I access a TiledMap object's type or a custom property that I have specified in Tiled Map Editor using TypeScript? I can't seem to find any way to do that. Are you supposed to read the .tmx file directly instead?

To illustrate the question better here's an image:

enter image description here


Solution

  • These two properties are grayed out, which means they are inherited, in this case from the tile referenced by the tile object.

    Inherited types or properties are not saved to the TMX file, unless they have been overridden (their presence in the TMX file indicates whether they have been overridden or not).

    Since you may still want these properties to be readily available rather than implementing the inheritance logic and object types file parsing in your engine, there is an Export option called "Resolve object types and properties" in the Preferences. Enable this and then choose File > Export As to export a map file with these properties explicitly written out.

    When you save your map file, the last export settings (target file and target format) are remembered, so next time you can just choose File > Export. In addition, you can enable "Repeat last export on save" in the Preferences to make this an entirely automated step.