Error no suitable conversion function from Cocos2d::Valuemap to Cocos2d::CCdictionary existis

Hi,

I’m following this amazing tutorial about implementing tilemaps in my game


But when i get to this:

CCTMXObjectGroup *objectGroup = _tileMap->objectGroupNamed("Objects");
 
if(objectGroup == NULL){
    CCLog("tile map has no objects object layer");
    return false;
}
 
CCDictionary *spawnPoint = objectGroup->objectNamed("SpawnPoint");
 
int x = ((CCString)*spawnPoint->valueForKey("x")).intValue();
int y = ((CCString)*spawnPoint->valueForKey("y")).intValue();
 
_player = new CCSprite();
_player->initWithFile("Player.png");
_player->setPosition(ccp(x,y));
 
this->addChild(_player);
this->setViewPointCenter(_player->getPosition());

I get an error on: CCDictionary *spawnPoint = objectGroup->objectNamed(“SpawnPoint”);
Stating that there is no function to convert this objectGroup.
(error no suitable conversion function from Cocos2d::Valuemap to Cocos2d::CCdictionary existis)

This looks like a problem from the diferents cocos’ versions used (The tutorial is v2 and i’m v3).

Does anyone knows how to fix this?

Never used this before, but a quick test and I got:

ValueMap spawnPoint = objectGroup->objectNamed("SpawnPoint");
or
auto spawnPoint = objectGroup->objectNamed("SpawnPoint");

followed by

int x = spawnPoint.at("x").asInt();
int y = spawnPoint.at("y").asInt();

Whether you choose ValueMap or auto is up to personal choice; they both do the exact same thing.