Tiled Layer层空报错问题

来源:互联网 发布:李子树下埋死人 知乎 编辑:程序博客网 时间:2024/06/07 02:38

<1>

TMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo){    TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo);        if (!tileset) {//added by DehengXu        return nullptr;    }        TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo);    // tell the layerinfo to release the ownership of the tiles map.    layerInfo->_ownTiles = false;    layer->setupTiles();    return layer;}

<2>

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) {//added by DehengXu                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++;        }    }}
<3>

// privateTMXLayer * TMXTiledMap::parseLayer(TMXLayerInfo *layerInfo, TMXMapInfo *mapInfo){    TMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo);        if (!tileset) {//added by DehengXu        return nullptr;    }    TMXLayer *layer = TMXLayer::create(tileset, layerInfo, mapInfo);    // tell the layerinfo to release the ownership of the tiles map.    layerInfo->_ownTiles = false;    layer->setupTiles();    return layer;}
<4>

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) {//added by DehengXu                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++;        }    }}



0 0
原创粉丝点击