mapeditor/tiled

Do you want to work on this issue?

You can request for a bounty in order to promote it!

Big problem with ID sprites #4018

ManPython posted onGitHub

Describe the bug The dock property for sprite_2 sprite_3 showing tile ID = 2, 3 4 in case in file is 484, 486

To Reproduce

Expected behavior This same ID in dock widget like file .tmx

Media not have time for this

Specifications:

  • OS: [e.g. Windows 10]
  • Tiled Version: 1.11

It sounds like you might be confusing the global tile IDs (GIDs) in the maps with the local tile IDs in tilesets. Since a map may contain multiple tilesets, it can't store the tile IDs directly, it has to distinguish between tiles from different tilesets that may have the same IDs. GIDs are a way to re-number tiles from different tilesets and thus remain unambiguous. More info in the docs: https://doc.mapeditor.org/en/stable/reference/global-tile-ids/

posted by eishiya 9 months ago

Then in property dock window we need both ID and GID coz hard to operate with of ID should be for collisions etc cases with algo game.

posted by ManPython 9 months ago

Strange.. I did not know that can be different ID.. in .tmx file is not separated.. but is dissonance when working with map and have some sprites to touch and identify for code.. I see repeatable ID on .tmx files but ID on file is different from GUI dock.

posted by ManPython 9 months ago

GIDs are a format-specific detail, they do not exist until you write the map out as a file, and different file formats may use different ways to disambiguate tilesets, not all of them use GIDs.

You should NOT be using GIDs as part of your game logic! They may be inconsistent between maps (if maps e.g. use different tilesets, or use the same tilesets in a different order), and they are a file format implementation detail. You should use data assigned to the actual tiles instead. At best, you can use the tile IDs, but ideally you should be using custom properties on the tiles.

You should not need to even look at tile IDs generally, Tiled provides much better tools for things like matching in-game data to specific tiles (or layers, or objects, or maps...).

posted by eishiya 9 months ago

Don't care.. need in app see the ID as .tmx file have.. coz nothing to do.. but bad case is to searching ID for sprite in .tmx file to recognize and control by code.

posted by ManPython 9 months ago

For my dock sprite ID is 5 and here in file 486.. etc.. then workflow is bad - and when 2 or more layers, worst. ids

posted by ManPython 9 months ago

Looks problem is more advanced or bug.. When adding more sprite and exporting to .tsx then no any ID for other sprites to identify, just metatiles have as first. Soo..in whole app is no option to find 484 that game should recognize and checking to control in some algo relations.

posted by ManPython 9 months ago

Finally comment.. there is no option to see GID in GUI app, only when preview .tmx file in some other editor like notepad.. this is bad case.

posted by ManPython 9 months ago

As I wrote before, GIDs are a file format implementation detail, not all map formats use them. So, they simply "don't exist" to be displayed in the GUI, they're only generated as needed if/when you write to a file format that uses them. Just like image editors don't let you view/edit the PNG data blocks directly, Tiled doesn't let you view/edit the GIDs - because they're not actually the map data, just a way to represent it in a text format. That you're making active use of them in your game beyond merely using them to reconstitute the map data is an unintended use case that is not likely to become supported.

posted by eishiya 9 months ago

Don't know what You trying explain.. and thats mind GIDs ID should be as "unknow" in GUI and not used in development? Each sprite added to map on second layer as coins for examples are far from ID.. and to discover colision must operate this ID from .tmx map..
Your explanation around PNG etc. images is far.. as eg. "Paint not offering see exif or edit", but here is example about basic function like identify pixels, where pixels on maps are ID or GIDs..

Then.. try to load to python .tmx file with pytmx libarary to operate collisions.. or something. I still must know with sprite ID on map layer I should pack in code and special actions.. and I can't predict each new added sprite..

Tiled doesn't let you view/edit the GIDs - because they're not actually the map data, just a way to represent it in a text format.

What a stupid explanation.. here.. GIDs are in tmx file as image I added 484.. it is a tile on layer. You probably missing facts that additional tilesets as sprites (characters, eg. coins, ) not terrain objects are shifted on some array of ID, then ID on maps and .tmx and GUI is this same but next tileset as sprite are not for identify, then.. search on .tmx layer with number app set on layer array..

Are you developing games with this app and gui? How you recognizing tile for collision like coins?

posted by ManPython 9 months ago

Yes, I am developing games with Tiled. I identify tiles by the method described on the GID documentation page I linked earlier - the GID tells me which tileset the tile is from, and which tile in that tileset it is. The GIDs are only relevant when reading the map in my game, at which point I create the data as used by my game directly (collision representation, lists of collectible items, drawables, etc). In my game I don't need to keep tile identifiers around after that, but if I did, I would use tile pointers, not GIDs, since a tile pointer is unique to the tile, while a single tile may have as many different GIDs as there are maps.

I don't understand what you're doing in your game. Either you're overcomplicating things, or you didn't read the documentation page I linked and are misunderstanding the function of the GIDs.

posted by eishiya 9 months ago

What is tile pointer for you? Looks like not GID?

But how you counting or mapping this IDs per sprite without checking .tmx file? The case is that I don't want to verify nothing in .tmx files coz why? But now must due GUI. I made example with tiles 64x64px where are just 4 tiles. I opened 128x128.png for this and named test1 then opened again this same file but name 128x128 in GUI then position of tiles in GUI was replaced to first in GUI, repeated this step and have two this same 128x128 . I was sure that firstgi=1 and firstgid=2 as next but is 5 next this same is 9.

Then if you developing games, how you doing identification for .png files if in developing process eg. adding more tiles, operating names as workflow? You trying manage names to be sure it is next after current tabs?

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="64" tileheight="64" infinite="0" nextlayerid="2" nextobjectid="1">
 <tileset firstgid="1" name="test" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="5" name="128x128" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="9" name="128x128" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <layer id="1" name="Tile Layer 1" width="30" height="20">
  <data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9,10,11,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5,6,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
 </layer>
</map>

Also is possible in GUI replace tile positions accidentally or as dev want when edit:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="64" tileheight="64" infinite="0" nextlayerid="2" nextobjectid="1">
 <tileset firstgid="1" name="test" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="5" name="128x128x2" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <grid orientation="orthogonal" width="128" height="128"/>
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
  <tile id="1"/>
  <tile id="2"/>
  <tile id="3"/>
  <tile id="0"/>
 </tileset>
 <tileset firstgid="9" name="128x128" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <tileset firstgid="13" name="test2" tilewidth="64" tileheight="64" tilecount="4" columns="2">
  <image source="../../../Game — draft/BG/128x128.png" trans="000000" width="128" height="128"/>
 </tileset>
 <layer id="1" name="Tile Layer 1" width="30" height="20">
  <data encoding="csv">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5,6,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
9,10,11,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
5,6,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</data>
 </layer>
</map>

The ID is this same for tiles but position in GUI is other.

Next case, adding next sprites and tiles but not 64x64 but 32x32.. so by this counting it's not so clear as + next similar size array for this.. Then do this twice, use in code counted id, and delete 2 last sprites and add next 2 as other.. coz developing.. again replace code (bad workflow). From my perspective in some cases counter should not be reset to continue ID.

  • edit: class vs type need to be resolved
posted by ManPython 9 months ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests