Animation tile numbers disallignment


(Bart Fernhout) #1

I report this under here, but do not known if this is a real bug.

When i make a animation and this is about 16 tiles long. This is all working fine. In the map editor the animation is showing nice.
Then i explort the map as a TMX file. Still no problem. But when i read the file in by using PureBasic the whole map is working but the animation is placed on the wrong place with one tile off, the rest of the animation is ok.

To explain:
I make a row of water wave. The row is animating trough the tiles. So it look like the water is waving from left to right.
The tile set is 9 tiles wide and 5 tiles high Thats including other tiles that are used to. On tile 28 trough 43 the tiles are in sequal to animate the wave. The first tile is number 28. When i look in the TMX file it say the first tile is 27. But in the data part the first animated tile is number 28.

Now i do understand the the tile counting may be starting with number 0 then the tile number 27 is correct. But the data set is counting with a start number 1. That is one number of.
Is there a reason why this is done. i has to correct the code in PureBasic to make it work.

Bart.


(Thorbjørn Lindeijer) #2

That is because the tile IDs referred to by the animation frames are local to the tileset, where the first tile in the tileset generally has tile ID 0.

In contrast, the tile IDs used by the layer data are global tile IDs, and can refer to any of the referenced tilesets (there can be more than one). For the global IDs, the first tile in the first tileset ends up starting at 1, because 0 is used to store empty tiles. Each referenced tileset stores the global ID of its first tile as the “firstgid” attribute.


(Bart Fernhout) #3

Thanks for the fast reply.

For me in PureBasic both arrays are global. The layer is inserted as a 2 dimension array. And the tiles it self in a 1 dimension array.
Both are starting using element number 1. In this way the one on one is maintained. I do not know how it work in c or c++ but in basic all kind of array’s starting with element 0.

But for me its easy now, that i know why this is done. So i can correct this by adding a 1 to the animation list. In this case the animation is working. I already try this and it looking good.

Slowly i start learning to use the full potential of Tiled. Before, I did use another tile/map maker and it had a external scripting to convert the map to PureBasic.
But the way Tiled use the TMX export is better. In this way the levels are easyer to made, correcting or expanding.

With a good friend we are trying to make a source code include for PureBasic. to use Tiled with a Export to TMX, so the source can read the file and no alteration have to be done to the TMX file to read the data in the correct way.

This is looking good for use. There are some things to research more to make the source code perfect connect to Tiled. When we are done i would like to present the file to all the users.

Bart.