-
Notifications
You must be signed in to change notification settings - Fork 153
Open
Description
Symptom
public inline function hasGid(Gid:Int):Bool
{
return (Gid >= firstGID) && Gid < (firstGID + numTiles);
}
is used to load the tilemap and always returns false because numTiles==0
.
Cause
numTiles
is calculated like this:
if (tileWidth > 0 && tileHeight > 0)
{
numRows = Std.int(imgHeight / tileHeight);
numCols = Std.int(imgWidth / tileWidth);
numTiles = numRows * numCols;
}
this might work for single image tilesets (I did not test that, but I suspect that is the case that was tested when writing this code). It does not work for this simple tileset:
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.11.2" name="tileset" tilewidth="111" tileheight="128" tilecount="2" columns="0">
<grid orientation="orthogonal" width="1" height="1"/>
<tile id="0">
<image source="../images/blue.png" width="111" height="128"/>
</tile>
<tile id="1">
<image source="../images/green.png" width="111" height="128"/>
</tile>
</tileset>
The loading code looks for imgWidth
and imgHeight
in what it assumes to be the image
node but will be a tile
node. That is, we are in the else case of this code:
if (source.hasNode.image)
{
// single image
node = source.node.image;
imageSource = node.att.source;
}
else
{
// several images
node = source.node.tile;
Note that even if we would take width and hight from the image
nodes, that would not make the calculation of numTiles
correct. The code is simply not equipped to deal with this case at all.
Metadata
Metadata
Assignees
Labels
No labels