tileson icon indicating copy to clipboard operation
tileson copied to clipboard

tson::Tileset:getTile() as parameter takes GID - not local tileset ID

Open Kedan opened this issue 10 months ago • 1 comments

As in title. This couse problems handling animations, when you using multiple tilesets on map: tson::Frame::getTileId() - return local tile ID, so tson::Tile *t = tson::Tileset::getTIle( tson::Frame::getTileID() ) - WILL FAIL - returns nullptr propably cousing segmentation fault.

What you have to do is:

  1. From current_tileset get std::vector<tson::Tile> vt = current_tileset.getTiles()
  2. int index = frame.getTileId() - 1; To be specific: its vector index, not some "tile ID".
  3. tson::Tile tile = vt[ index ] now you can get drawing rect (but you MUST correct its dimensions id you use tilesets with different tile sizes )

Kedan avatar Mar 31 '24 21:03 Kedan