I am using the CocoSharp.PCL.Shared Nuget version 1.6.2 and I am trying to get the tile property.
Here is the TileSet.tsx:
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.2" tiledversion="1.2.1" name="wood_tileset" tilewidth="32" tileheight="32" tilecount="256" columns="16">
<image source="wood_tileset.png" width="512" height="512"/>
<tile id="68">
<properties>
<property name="IsTreasure" value="true"/>
</properties>
</tile>
</tileset>
The function I call to get my property:
void HandleCustomTilePropertyAt(int worldX, int worldY, CCTileMapLayer layer)
{
CCTileMapCoordinates tileAtXy = layer.ClosestTileCoordAtNodePosition(new CCPoint(worldX, worldY));
CCTileGidAndFlags info = layer.TileGIDAndFlags(tileAtXy.Column, tileAtXy.Row);
if (info != null && info.Gid == 68)
{
Dictionary<string, string> properties = null;
try
{
properties = tileMap.TilePropertiesForGID(info.Gid);
}
catch
{
// CocosSharp
}
if (properties != null && properties.ContainsKey("IsTreasure") && properties["IsTreasure"] == "true" )
{
layer.RemoveTile(tileAtXy);
// todo: Create a treasure chest entity
}
}
}
The problem is that : properties = tileMap.TilePropertiesForGID(info.Gid);
always return null.
But if I break and look into the non-public variable, I can see the property of my tile :
What am I doing wrong ?