本文整理汇总了C++中TMXMapInfo::setLayerAttribs方法的典型用法代码示例。如果您正苦于以下问题:C++ TMXMapInfo::setLayerAttribs方法的具体用法?C++ TMXMapInfo::setLayerAttribs怎么用?C++ TMXMapInfo::setLayerAttribs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TMXMapInfo
的用法示例。
在下文中一共展示了TMXMapInfo::setLayerAttribs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startElement
//.........这里部分代码省略.........
objectGroup->setPositionOffset(positionOffset);
tmxMapInfo->getObjectGroups().pushBack(objectGroup);
objectGroup->release();
// The parent element is now "objectgroup"
tmxMapInfo->setParentElement(TMXPropertyObjectGroup);
}
else if (elementName == "image")
{
TMXTilesetInfo* tileset = tmxMapInfo->getTilesets().back();
// build full path
std::string imagename = attributeDict["source"].asString();
tileset->_originSourceImage = imagename;
if (_TMXFileName.find_last_of("/") != string::npos)
{
string dir = _TMXFileName.substr(0, _TMXFileName.find_last_of("/") + 1);
tileset->_sourceImage = dir + imagename;
}
else
{
tileset->_sourceImage = _resources + (_resources.size() ? "/" : "") + imagename;
}
}
else if (elementName == "data")
{
std::string encoding = attributeDict["encoding"].asString();
std::string compression = attributeDict["compression"].asString();
if (encoding == "")
{
tmxMapInfo->setLayerAttribs(tmxMapInfo->getLayerAttribs() | TMXLayerAttribNone);
TMXLayerInfo* layer = tmxMapInfo->getLayers().back();
Size layerSize = layer->_layerSize;
int tilesAmount = layerSize.width*layerSize.height;
uint32_t *tiles = (uint32_t*) malloc(tilesAmount*sizeof(uint32_t));
// set all value to 0
memset(tiles, 0, tilesAmount*sizeof(int));
layer->_tiles = tiles;
}
else if (encoding == "base64")
{
int layerAttribs = tmxMapInfo->getLayerAttribs();
tmxMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribBase64);
tmxMapInfo->setStoringCharacters(true);
if (compression == "gzip")
{
layerAttribs = tmxMapInfo->getLayerAttribs();
tmxMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribGzip);
} else
if (compression == "zlib")
{
layerAttribs = tmxMapInfo->getLayerAttribs();
tmxMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribZlib);
}
CCASSERT( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" );
}
}
else if (elementName == "object")
{