TSX files portable?

I see that the paths for the tiles and tilesets are included in the XML for the TSX file.

What’s the best way to make the TSX files portable?

I think it is also possible to use <data> in the image instead of having a source path for it and thus avoid having two files, but this makes editing a pain in the butt and isn’t officially supported as far as I know, and there are no plans to make this easier: Embedded images (as base64) in json format · Issue #1957 · mapeditor/tiled · GitHub (in addition to Python mentioned in that issue, you can also achieve this via JavaScript).

You should expect to deal with related files in general when you do gamedev or map building, whether from your own files or those from others, so good file management practice pays off:

  • Keep your project files within a single parent directory dedicated to the project.
    This’ll keep the paths simple, let you easily copy the whole project over, and it’ll keep unrelated files from getting in the way.
  • Keep your Tileset files and images either next to the maps and to each other, or place them in a subdirectory.
    This lets you organise your files without making the paths complicated.
  • If you store your images/maps/tilesets in separate directories, avoid going more than one step up. ../images/grassland.png is fine, but ../../images/grassland.png starts to get confusing and increases the risk that the directories will be shared independently of one another.

Keeping your files together and simply organised keeps the relative paths simple, so that even if the files do somehow end up structured incorrectly, the structure will be trivial to rebuild.

In short, no?

What I want to be able to do is share .TMX and .TSX files. However, the file paths are hard-coded into the XML, so unless someone else’s setup is EXACTLY the same, it’s not going to work.

I’m trying to share my content with another developer, and this is a real pain, as our environments aren’t the same (drive letter comes most immediately to mind, but paths are there too).

Tilesets could be used across projects, for example, or be shared with various developers (or want to publish them online)

If that’s the case, it’d be nice to have a function that let me bundle up/export all the associated tilesets and file, so that someone else could import them and have them work.

Paths in Tiled files are relative, so if you follow my suggestions above, their set-up should be no problem. The only thing that needs to be consistent is the structure of the project directory, which is trivial if you keep it simple.

Keeping project directory structures consistent is a common requirement in gamedev- some engines hide the file management from you and enforce their own, but there’s still an underlying restriction on your file structures.

Perhaps I’m misunderstanding. When I look at the XML the entire path is hard-coded.

Tiled writes absolute paths the file is referencing a file that’s on a different drive, because relative paths are not possible in that case. If your files are organised in a project directory, then there would be no absolute paths.