I have set up a tile map in Tiled with an object layer for some blocks which I have assigned the "Colour" property for (green,blue or yellow)
I am trying to use the following code to read the tile object properties and check for a particular colour attribute.
However, the code within the if statement never executes even though the strings match when I debug the code. Can anyone suggest what I am doing wrong, or if there is a better way to compare the value of the property string to another string?
CCTMXObjectGroup *blocktiles = tilemap->objectGroupNamed("Blocks");
CCMutableArray *allBlocks = blocktiles->getObjects();
CCMutableArray::CCMutableArrayIterator it;
CCString* sGreen = new CCString("green");
for (it = allBlocks->begin(); it != allBlocks->end(); ++it)
{
if ((*it)->objectForKey("Colour") == sGreen);
{
this->createBlock(ccp(xpos, ypos), green);
}
}
Thanks.
Never mind, I have solved this.
CCString *BlockColour = (*it)>objectForKey;>createBlock(ccp(xpos, ypos), green);
if .compare == 0)
{
this
}