Sprite location in spritesheet on export

Is there a way to get the location (x, y) of the sprite that is being used on the map when exporting without manually putting in the coordinates in the property of the tile?

Right now I get the number the tile is within the tile sheet. But I don’t know the starting point of the sprite in question within the tile sheet. So the number 614 doesn’t really help me when writing something to import the map if I want to map. I currently have to do this manually. Is there something I am missing or something I can add that will do this for me?

Hmm, actually even Tiled does not really know this because it is using those numbers to get at the tiles when drawing the map for example.

If you know the number of tile columns in your tileset, you can derive the x/y as follows:

int tileIndex = 614;
int row = tileIndex / columnCount;
int column = tileIndex % columnCount;
int x = column * tileWidth;
int y = row * tileHeight;

But I realize this is probably what you are doing already.

I don’t fully understand why you need this information and are even mentioning to put these in tile properties, when it can be readily derived?

It is more or less to keep the import process cleaner. It’s a lot easier to call tile.spritelocation.x then it is to call an external method that does the above code function and pass parameters along. It is more of a nice to have type of feature and I wanted to double check to make sure it wasn’t something already included that I needed to turn on or add.

But you only need to write that method once, and from there on, there is virtually no difference between tile.spritelocation.x and tile.getspritelocation().x. If you’re worried about computational overhead, you could just write a one-time loop that sets these locations.

If you really want it in the export, you can write your own map exporter that includes this information, but it’s much easier to code this at the importer side, right?

I don’t disagree that it is difficult to write the function myself. I was only asking if there was something in the program that could sidestep the process.