本文整理汇总了C++中CCTMXMapInfo::setLayerAttribs方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTMXMapInfo::setLayerAttribs方法的具体用法?C++ CCTMXMapInfo::setLayerAttribs怎么用?C++ CCTMXMapInfo::setLayerAttribs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTMXMapInfo
的用法示例。
在下文中一共展示了CCTMXMapInfo::setLayerAttribs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startElement
//.........这里部分代码省略.........
pTMXMapInfo->getObjectGroups()->addObject(objectGroup);
objectGroup->release();
// The parent element is now "objectgroup"
pTMXMapInfo->setParentElement(TMXPropertyObjectGroup);
}
else if (elementName == "image")
{
CCTMXTilesetInfo* tileset = (CCTMXTilesetInfo*)pTMXMapInfo->getTilesets()->lastObject();
// build full path
std::string imagename = valueForKey("source", attributeDict);
if (m_sTMXFileName.find_last_of("/") != string::npos)
{
string dir = m_sTMXFileName.substr(0, m_sTMXFileName.find_last_of("/") + 1);
tileset->m_sSourceImage = dir + imagename;
}
else
{
tileset->m_sSourceImage = m_sResources + (m_sResources.size() ? "/" : "") + imagename;
}
}
else if (elementName == "data")
{
std::string encoding = valueForKey("encoding", attributeDict);
std::string compression = valueForKey("compression", attributeDict);
if( encoding == "base64" )
{
int layerAttribs = pTMXMapInfo->getLayerAttribs();
pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribBase64);
pTMXMapInfo->setStoringCharacters(true);
if( compression == "gzip" )
{
layerAttribs = pTMXMapInfo->getLayerAttribs();
pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribGzip);
} else
if (compression == "zlib")
{
layerAttribs = pTMXMapInfo->getLayerAttribs();
pTMXMapInfo->setLayerAttribs(layerAttribs | TMXLayerAttribZlib);
}
CCAssert( compression == "" || compression == "gzip" || compression == "zlib", "TMX: unsupported compression method" );
}
CCAssert( pTMXMapInfo->getLayerAttribs() != TMXLayerAttribNone, "TMX tile map: Only base64 and/or gzip/zlib maps are supported" );
}
else if (elementName == "object")
{
char buffer[32] = {0};
CCTMXObjectGroup* objectGroup = (CCTMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject();
// The value for "type" was blank or not a valid class name
// Create an instance of TMXObjectInfo to store the object and its properties
CCDictionary *dict = new CCDictionary();
// Parse everything automatically
const char* pArray[] = {"name", "type", "width", "height", "gid"};
for(size_t i = 0; i < sizeof(pArray)/sizeof(pArray[0]); ++i )
{
const char* key = pArray[i];
CCString* obj = new CCString(valueForKey(key, attributeDict));