mirror of https://github.com/axmolengine/axmol.git
issue #1686:synchronize CCTMXXMLParser.cpp
This commit is contained in:
parent
98249b4754
commit
9d07778bb0
|
@ -75,6 +75,7 @@ CCTMXLayerInfo::CCTMXLayerInfo()
|
|||
{
|
||||
m_pProperties= new CCDictionary();;
|
||||
}
|
||||
|
||||
CCTMXLayerInfo::~CCTMXLayerInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing.");
|
||||
|
@ -177,6 +178,7 @@ void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePat
|
|||
m_bStoringCharacters = false;
|
||||
m_nLayerAttribs = TMXLayerAttribNone;
|
||||
m_nParentElement = TMXPropertyNone;
|
||||
m_uCurrentFirstGID = 0;
|
||||
}
|
||||
bool CCTMXMapInfo::initWithXML(const char* tmxString, const char* resourcePath)
|
||||
{
|
||||
|
@ -200,8 +202,10 @@ CCTMXMapInfo::CCTMXMapInfo()
|
|||
, m_bStoringCharacters(false)
|
||||
, m_pProperties(NULL)
|
||||
, m_pTileProperties(NULL)
|
||||
, m_uCurrentFirstGID(0)
|
||||
{
|
||||
}
|
||||
|
||||
CCTMXMapInfo::~CCTMXMapInfo()
|
||||
{
|
||||
CCLOGINFO("cocos2d: deallocing.");
|
||||
|
@ -211,40 +215,48 @@ CCTMXMapInfo::~CCTMXMapInfo()
|
|||
CC_SAFE_RELEASE(m_pTileProperties);
|
||||
CC_SAFE_RELEASE(m_pObjectGroups);
|
||||
}
|
||||
|
||||
CCArray* CCTMXMapInfo::getLayers()
|
||||
{
|
||||
return m_pLayers;
|
||||
}
|
||||
|
||||
void CCTMXMapInfo::setLayers(CCArray* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
CC_SAFE_RELEASE(m_pLayers);
|
||||
m_pLayers = var;
|
||||
}
|
||||
|
||||
CCArray* CCTMXMapInfo::getTilesets()
|
||||
{
|
||||
return m_pTilesets;
|
||||
}
|
||||
|
||||
void CCTMXMapInfo::setTilesets(CCArray* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
CC_SAFE_RELEASE(m_pTilesets);
|
||||
m_pTilesets = var;
|
||||
}
|
||||
|
||||
CCArray* CCTMXMapInfo::getObjectGroups()
|
||||
{
|
||||
return m_pObjectGroups;
|
||||
}
|
||||
|
||||
void CCTMXMapInfo::setObjectGroups(CCArray* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
CC_SAFE_RELEASE(m_pObjectGroups);
|
||||
m_pObjectGroups = var;
|
||||
}
|
||||
|
||||
CCDictionary * CCTMXMapInfo::getProperties()
|
||||
{
|
||||
return m_pProperties;
|
||||
}
|
||||
|
||||
void CCTMXMapInfo::setProperties(CCDictionary* var)
|
||||
{
|
||||
CC_SAFE_RETAIN(var);
|
||||
|
@ -295,7 +307,7 @@ bool CCTMXMapInfo::parseXMLFile(const char *xmlFilename)
|
|||
|
||||
parser.setDelegator(this);
|
||||
|
||||
return parser.parse(xmlFilename);
|
||||
return parser.parse(CCFileUtils::sharedFileUtils()->fullPathForFilename(xmlFilename).c_str());
|
||||
}
|
||||
|
||||
|
||||
|
@ -350,6 +362,7 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
std::string externalTilesetFilename = valueForKey("source", attributeDict);
|
||||
if (externalTilesetFilename != "")
|
||||
{
|
||||
// Tileset file will be relative to the map file. So we need to convert it to an absolute path
|
||||
if (m_sTMXFileName.find_last_of("/") != string::npos)
|
||||
{
|
||||
string dir = m_sTMXFileName.substr(0, m_sTMXFileName.find_last_of("/") + 1);
|
||||
|
@ -361,13 +374,23 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts)
|
|||
}
|
||||
externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathForFilename(externalTilesetFilename.c_str());
|
||||
|
||||
m_uCurrentFirstGID = (unsigned int)atoi(valueForKey("firstgid", attributeDict));
|
||||
|
||||
pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
CCTMXTilesetInfo *tileset = new CCTMXTilesetInfo();
|
||||
tileset->m_sName = valueForKey("name", attributeDict);
|
||||
if (m_uCurrentFirstGID == 0)
|
||||
{
|
||||
tileset->m_uFirstGid = (unsigned int)atoi(valueForKey("firstgid", attributeDict));
|
||||
}
|
||||
else
|
||||
{
|
||||
tileset->m_uFirstGid = m_uCurrentFirstGID;
|
||||
m_uCurrentFirstGID = 0;
|
||||
}
|
||||
tileset->m_uSpacing = (unsigned int)atoi(valueForKey("spacing", attributeDict));
|
||||
tileset->m_uMargin = (unsigned int)atoi(valueForKey("margin", attributeDict));
|
||||
CCSize s;
|
||||
|
|
|
@ -209,6 +209,7 @@ protected:
|
|||
std::string m_sCurrentString;
|
||||
//! tile properties
|
||||
CCDictionary* m_pTileProperties;
|
||||
unsigned int m_uCurrentFirstGID;
|
||||
};
|
||||
|
||||
// end of tilemap_parallax_nodes group
|
||||
|
|
Loading…
Reference in New Issue