Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since cocos2d is limited to one tileset per layer, each tile layer actually has a tileset reference:</p> <pre><code>CCTMXLayer* floorLayer = [tilemap layerNamed:@"floortiles"]; CCTMXTilesetInfo* tileset = floorLayer.tileset; uint32_t firstGID = tileset.firstGID; </code></pre> <p>So far, so good. But what's the max GID? This can be obtained for all tilesets except for the last rather easily. Assuming you have two tile layers with different tilesets, then the second layer's firstGID subtracted by one is the previous layer's maxGID.</p> <p>For the last layer you can assume that the maxGID is the number of possible tiles in the tileset. However this does not account for tilesets that aren't completely filled with actual tiles. The other option is to iterate over all layers using this tileset and recording the highest GID in use. Again this is flawed because the tile with the highest GID may not actually be placed on the map.</p> <p>The only definite solution to work around this is to add a dummy layer and add the highest GID to it at 0,0 and then check the tile GID of that position on the dummy layer. That's how you know for sure what the highest GID of a tileset is. Provided there is no human error in the process and you remember to update the tile if you add more tiles to the tileset.</p> <p>The only other way to accurately infer this information programmatically is scanning the texture and excluding all unused tiles, by checking each tile area and find the first one that's totally transparent or single (specific) color. This will only work if your tileset is filled left to right, top to bottom without any "empty" tiles in between.</p> <p>From all these options the one I use in <a href="http://www.koboldtouch.com" rel="nofollow">KoboldTouch</a> is to simply assume that the tileset with the highest-most firstGID value is entirely filled with tiles, meaning lastGID will be:</p> <pre><code>uint32_t lastGID = firstGID + (texWidth/tileWidth) * (texHeight/tileHeight) - 1; </code></pre> <p>That's good enough for almost all cases.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload