I dug through the source code a bit and I notice that the setTileGID:at: method does a comparison:
unsigned int currentGID = [self tileGIDAt:pos];
if( currentGID != gid ) {
AtlasSprite *tile = [self tileAt:pos];
if( ! tile ) {
tile = [self addTileForGID:gid at:pos];
} else {
CGRect rect = [tileset_ tileForGID:gid];
[tile setTextureRect:rect];
}
// update gid on map
int idx = pos.x + pos.y * layerSize_.width;
tiles_[ idx ] = gid;
}
The method does a comparison for currentGID against the GID you pass in.
In my test I was running i was setting the tile with a GID of 1, then removing the tile with removeTileAt method, then setting the gid back to 1 (using setTileGID:at:). Inside the method it still thinks its currentGID is 1 so it will do nothing, and hence not "add" the tile back.
Should the currentGID be 0 to indicate no tile, since I removed it previously?
IS this an issue with timing? a possible bug? or am I using the tiles in a manner that isn't supposed to be used?