1

When constructing a TMXTiledMap instance with Cocos2D-X, how can one access an object custom properties ?

I can see that TMXObjectGroup provides a getObject method

ValueMap getObject (const std::string &objectName) const 

but how do I access unnamed objects within a loop ? There is a getObjects() method which returns a vector of Value but what are the values in that case?

Antoine Lassauzay
  • 1,557
  • 11
  • 12

1 Answers1

1

they are a ValueMap (std::unordered_map<std::string, Value>) of the properties for that object:

auto& objects = group->getObjects();
for (auto &obj : objects) {
    auto &properties = obj.asValueMap();
    cc_log(properties["type"].asString());
}