本文整理汇总了C++中CCTMXMapInfo::getProperties方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTMXMapInfo::getProperties方法的具体用法?C++ CCTMXMapInfo::getProperties怎么用?C++ CCTMXMapInfo::getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTMXMapInfo
的用法示例。
在下文中一共展示了CCTMXMapInfo::getProperties方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithTMXFile
bool CCTMXTiledMap::initWithTMXFile(const char *tmxFile)
{
NSAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi nil");
setContentSize(CGSizeZero);
CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithTMXFile(tmxFile);
NSAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
m_tMapSize = mapInfo->getMapSize();
m_tTileSize = mapInfo->getTileSize();
m_nMapOrientation = mapInfo->getOrientation();
setObjectGroups(mapInfo->getObjectGroups());
setProperties(mapInfo->getProperties());
CCX_SAFE_RELEASE(m_pTileProperties);
m_pTileProperties = mapInfo->getTileProperties();
CCX_SAFE_RETAIN(m_pTileProperties);
int idx = 0;
NSMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
if (layers && layers->count()>0)
{
CCTMXLayerInfo *layerInfo = NULL;
NSMutableArray<CCTMXLayerInfo*>::NSMutableArrayIterator it;
for (it = layers->begin(); it != layers->end(); ++it)
{
layerInfo = *it;
if (layerInfo && layerInfo->m_bVisible)
{
CCTMXLayer *child = parseLayer(layerInfo, mapInfo);
addChild((CCNode*)child, idx, idx);
// update content size with the max size
CGSize childSize = child->getContentSize();
CGSize currentSize = this->getContentSize();
currentSize.width = MAX( currentSize.width, childSize.width );
currentSize.height = MAX( currentSize.height, childSize.height );
this->setContentSize(currentSize);
idx++;
}
}
}
return true;
}
示例2: startElement
//.........这里部分代码省略.........
// Y
value = valueForKey("y", attributeDict);
if (value) {
int y = atoi(value) + (int)objectGroup->getPositionOffset().y;
// Correct y position. (Tiled uses Flipped, cocos2d uses Standard)
y = (int)(m_tMapSize.height * m_tTileSize.height) - y - atoi(valueForKey("height", attributeDict));
sprintf(buffer, "%d", y);
CCString* pStr = new CCString(buffer);
pStr->autorelease();
dict->setObject(pStr, "y");
}
// Add the object to the objectGroup
objectGroup->getObjects()->addObject(dict);
dict->release();
// The parent element is now "object"
pTMXMapInfo->setParentElement(TMXPropertyObject);
}
else if (elementName == "property")
{
if ( pTMXMapInfo->getParentElement() == TMXPropertyNone )
{
CCLOG( "TMX tile map: Parent element is unsupported. Cannot add property named '%s' with value '%s'",
valueForKey("name", attributeDict), valueForKey("value",attributeDict) );
}
else if ( pTMXMapInfo->getParentElement() == TMXPropertyMap )
{
// The parent element is the map
CCString *value = new CCString(valueForKey("value", attributeDict));
std::string key = valueForKey("name", attributeDict);
pTMXMapInfo->getProperties()->setObject(value, key.c_str());
value->release();
}
else if ( pTMXMapInfo->getParentElement() == TMXPropertyLayer )
{
// The parent element is the last layer
CCTMXLayerInfo* layer = (CCTMXLayerInfo*)pTMXMapInfo->getLayers()->lastObject();
CCString *value = new CCString(valueForKey("value", attributeDict));
std::string key = valueForKey("name", attributeDict);
// Add the property to the layer
layer->getProperties()->setObject(value, key.c_str());
value->release();
}
else if ( pTMXMapInfo->getParentElement() == TMXPropertyObjectGroup )
{
// The parent element is the last object group
CCTMXObjectGroup* objectGroup = (CCTMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject();
CCString *value = new CCString(valueForKey("value", attributeDict));
const char* key = valueForKey("name", attributeDict);
objectGroup->getProperties()->setObject(value, key);
value->release();
}
else if ( pTMXMapInfo->getParentElement() == TMXPropertyObject )
{
// The parent element is the last object
CCTMXObjectGroup* objectGroup = (CCTMXObjectGroup*)pTMXMapInfo->getObjectGroups()->lastObject();
CCDictionary* dict = (CCDictionary*)objectGroup->getObjects()->lastObject();
const char* propertyName = valueForKey("name", attributeDict);
CCString *propertyValue = new CCString(valueForKey("value", attributeDict));
示例3: initWithTMXFile
bool CCTMXTiledMap::initWithTMXFile(const char *tmxFile)
{
CCAssert(tmxFile != NULL && strlen(tmxFile)>0, "TMXTiledMap: tmx file should not bi nil");
setContentSize(CCSizeZero);
CCTMXMapInfo *mapInfo = CCTMXMapInfo::formatWithTMXFile(tmxFile);
if (! mapInfo)
{
return false;
}
CCAssert( mapInfo->getTilesets()->count() != 0, "TMXTiledMap: Map not found. Please check the filename.");
m_tMapSize = mapInfo->getMapSize();
m_tTileSize = mapInfo->getTileSize();
m_nMapOrientation = mapInfo->getOrientation();
setObjectGroups(mapInfo->getObjectGroups());
setProperties(mapInfo->getProperties());
CC_SAFE_RELEASE(m_pTileProperties);
m_pTileProperties = mapInfo->getTileProperties();
CC_SAFE_RETAIN(m_pTileProperties);
int idx = 0;
CCMutableArray<CCTMXLayerInfo*>* layers = mapInfo->getLayers();
if (layers && layers->count()>0)
{
if (NULL == m_pTMXLayers)
{
m_pTMXLayers = new CCDictionary<std::string, CCTMXLayer*>();
CCAssert(m_pTMXLayers, "Allocate memory failed!");
}
CCTMXLayerInfo *layerInfo = NULL;
CCMutableArray<CCTMXLayerInfo*>::CCMutableArrayIterator it;
for (it = layers->begin(); it != layers->end(); ++it)
{
layerInfo = *it;
if (layerInfo && layerInfo->m_bVisible)
{
CCTMXLayer *child = parseLayer(layerInfo, mapInfo);
addChild((CCNode*)child, idx, idx);
// record the CCTMXLayer object by it's name
std::string layerName = child->getLayerName();
m_pTMXLayers->setObject(child, layerName);
// update content size with the max size
const CCSize& childSize = child->getContentSize();
CCSize currentSize = this->getContentSize();
currentSize.width = MAX( currentSize.width, childSize.width );
currentSize.height = MAX( currentSize.height, childSize.height );
this->setContentSize(currentSize);
idx++;
}
}
}
return true;
}