# How can i get a value from object in tmx file in Cocos2d x 3.x?

I want to set my sprite in x coordinate based on an object in TMX map file, this is my code:

tileMap = cocos2d::TMXTiledMap::create("ground.tmx");
ground = tileMap->layerNamed("ground");
this->addChild(tileMap);

TMXObjectGroup *objects = tileMap->objectGroupNamed("objects");
Dictionary *sign = (Dictionary*)objects->objectNamed("sign");


How can i get a value of object in tmx file in Cocos2d x ?

## 1 Answer

ValueMap sign = objects->getObject("sign");
float x = sign["x"].asFloat();
float y = sign["y"].asFloat();
std::string nameAlias =  sign["name_alias"].asString();


In cocos2d v.3.8, objectNamed("name") will return ValueMap type that contains Value type. You can see in CCValue.h for more details.