void TMXTiledMap::buildWithMapInfo(TMXMapInfo* mapInfo) { _mapSize = mapInfo->getMapSize(); _tileSize = mapInfo->getTileSize(); _mapOrientation = mapInfo->getOrientation(); _objectGroups = mapInfo->getObjectGroups(); _properties = mapInfo->getProperties(); _tileProperties = mapInfo->getTileProperties(); int idx = 0; auto& layers = mapInfo->getLayers(); for (const auto &layerInfo : layers) { if (layerInfo->_visible) { TMXLayer *child = parseLayer(layerInfo, mapInfo); if (child == nullptr) { idx++; continue; } addChild(child, idx, idx); // update content size with the max size const Size& childSize = child->getContentSize(); Size currentSize = this->getContentSize(); currentSize.width = std::max(currentSize.width, childSize.width); currentSize.height = std::max(currentSize.height, childSize.height); this->setContentSize(currentSize); idx++; } } _tmxLayerNum = idx; }